00001 #include <boost/test/auto_unit_test.hpp> 00002 00003 #include "SequenceHash.hpp" 00004 00005 using namespace benzene; 00006 00007 //--------------------------------------------------------------------------- 00008 00009 namespace { 00010 00011 BOOST_AUTO_TEST_CASE(SequenceHash_Hash) 00012 { 00013 PointSequence a, b; 00014 00015 BOOST_CHECK_EQUAL(SequenceHash::Hash(a), 0u); 00016 00017 a.push_back(HEX_CELL_A1); 00018 b.push_back(HEX_CELL_A1); 00019 BOOST_CHECK(SequenceHash::Hash(a) == SequenceHash::Hash(b)); 00020 00021 a.push_back(HEX_CELL_A2); 00022 b.push_back(HEX_CELL_A3); 00023 BOOST_CHECK(SequenceHash::Hash(a) != SequenceHash::Hash(b)); 00024 00025 // a = {1,2,3}, b = {1,3,2} 00026 a.push_back(HEX_CELL_A3); 00027 b.push_back(HEX_CELL_A2); 00028 BOOST_CHECK(SequenceHash::Hash(a) != SequenceHash::Hash(b)); 00029 00030 // a = {1,2,3}, b = {3,2,1} 00031 b.clear(); 00032 b.push_back(HEX_CELL_A3); 00033 b.push_back(HEX_CELL_A2); 00034 b.push_back(HEX_CELL_A1); 00035 BOOST_CHECK(SequenceHash::Hash(a) != SequenceHash::Hash(b)); 00036 00037 // a = {1,2,3}, b = {} 00038 b.clear(); 00039 BOOST_CHECK(SequenceHash::Hash(a) != SequenceHash::Hash(b)); 00040 00041 // a = {1,2,3}, b = {1} 00042 b.push_back(HEX_CELL_A1); 00043 BOOST_CHECK(SequenceHash::Hash(a) != SequenceHash::Hash(b)); 00044 00045 // a = {1,2,3}, b = {1,2} 00046 b.push_back(HEX_CELL_A2); 00047 BOOST_CHECK(SequenceHash::Hash(a) != SequenceHash::Hash(b)); 00048 00049 // a = {1,2,3}, b = {1,2,3} 00050 b.push_back(HEX_CELL_A3); 00051 BOOST_CHECK(SequenceHash::Hash(a) == SequenceHash::Hash(b)); 00052 } 00053 00054 } 00055 00056 //---------------------------------------------------------------------------