diff options
author | Thomas Winget <tewinget@gmail.com> | 2014-09-24 23:50:51 -0400 |
---|---|---|
committer | Thomas Winget <tewinget@gmail.com> | 2014-09-24 23:50:51 -0400 |
commit | 145dc19eebd2c9f289381debfa1fb7a4b8c71ef7 (patch) | |
tree | c511ed7ecb8b3bdd2da26e55801d20f6326f656a /tests/unit_tests/serialization.cpp | |
parent | Merge pull request #159 (diff) | |
parent | Remove LDNS dep and fix a bug in libunbound const correctness fix (diff) | |
download | monero-145dc19eebd2c9f289381debfa1fb7a4b8c71ef7.tar.xz |
Merge pull request #160 from tewinget/remove_ldns_dep
Remove ldns dependency
Diffstat (limited to 'tests/unit_tests/serialization.cpp')
-rw-r--r-- | tests/unit_tests/serialization.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/unit_tests/serialization.cpp b/tests/unit_tests/serialization.cpp index 4a254b5a4..3ae5bcdf6 100644 --- a/tests/unit_tests/serialization.cpp +++ b/tests/unit_tests/serialization.cpp @@ -299,6 +299,37 @@ namespace } } +bool test_get_varint_packed_size_for_num(uint64_t n) +{ +std::stringstream ss; +typedef std::ostreambuf_iterator<char> it; +tools::write_varint(it(ss), n); +uint64_t sz = ss.str().size(); +if(sz != tools::get_varint_packed_size(n)) +return false; +else +return true; +} +TEST(Serialization, validate_get_varint_packed_size) +{ +ASSERT_TRUE(test_get_varint_packed_size_for_num(127)); +ASSERT_TRUE(test_get_varint_packed_size_for_num(128)); +ASSERT_TRUE(test_get_varint_packed_size_for_num(16383)); +ASSERT_TRUE(test_get_varint_packed_size_for_num(16383+1)); +ASSERT_TRUE(test_get_varint_packed_size_for_num(2097151)); +ASSERT_TRUE(test_get_varint_packed_size_for_num(2097151+1)); +ASSERT_TRUE(test_get_varint_packed_size_for_num(268435455)); +ASSERT_TRUE(test_get_varint_packed_size_for_num(268435455+1)); +ASSERT_TRUE(test_get_varint_packed_size_for_num(34359738367)); +ASSERT_TRUE(test_get_varint_packed_size_for_num(34359738367+1)); +ASSERT_TRUE(test_get_varint_packed_size_for_num(4398046511103)); +ASSERT_TRUE(test_get_varint_packed_size_for_num(4398046511103+1)); +ASSERT_TRUE(test_get_varint_packed_size_for_num(4398046511103)); +ASSERT_TRUE(test_get_varint_packed_size_for_num(4398046511103+1)); +ASSERT_TRUE(test_get_varint_packed_size_for_num(562949953421311)); +ASSERT_TRUE(test_get_varint_packed_size_for_num(562949953421311+1)); +} + TEST(Serialization, serializes_transacion_signatures_correctly) { using namespace cryptonote; |