Skip to content

Commit

Permalink
Increase test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
lmrodriguezr committed Jan 23, 2024
1 parent e840b32 commit 8b16de1
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/net_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,24 @@ def test_download_file_ftp
### m.download_file_ftp(:miga_db, '../api_test.txt', f)
### assert_equal('miga', File.read(f).chomp)
end

def test_encoding
# Test original encoding
t1 = '()!@*#àøo'
t2 = "#{t1}"
assert_equal(t1, t2)
assert_equal(t1, MiGA::MiGA.normalize_encoding(t2))

# Test with a different encoding
t2 = t2.encode('windows-1252')
assert_equal('Windows-1252', t2.encoding_to_s)
assert_not_equal(t1, t2)
assert_equal(t1, MiGA::MiGA.normalize_encoding(t2))

# Test with a different encoding wrongly declared
t2.force_encoding('utf-8')
assert_equal('UTF-8', t2.encoding_to_s)
assert_not_equal(t1, t2)
assert_equal(t1, MiGA::MiGA.normalize_encoding(t2))
end
end

0 comments on commit 8b16de1

Please sign in to comment.