null+****@clear*****
null+****@clear*****
2011年 11月 10日 (木) 15:29:51 JST
Susumu Yata 2011-11-10 06:29:51 +0000 (Thu, 10 Nov 2011) New Revision: 1ebd8546a7d3a7f680eb463d7ce7d4469cb19c7c Log: replace cut_assert() by cppcut_assert_equal(). Modified files: test/unit/core/dat/test-key.cpp test/unit/core/dat/test-node.cpp test/unit/core/dat/test-string.cpp Modified: test/unit/core/dat/test-key.cpp (+10 -1) =================================================================== --- test/unit/core/dat/test-key.cpp 2011-11-10 05:55:07 +0000 (9f94952) +++ test/unit/core/dat/test-key.cpp 2011-11-10 06:29:51 +0000 (57c0aae) @@ -23,6 +23,15 @@ #include <dat/key.hpp> #include <cstring> +#include <iostream> + +namespace cut +{ + std::ostream &operator<<(std::ostream &stream, const grn::dat::String &str) + { + return stream.write(static_cast<const char *>(str.ptr()), str.length()); + } +} namespace test_dat_key { @@ -53,7 +62,7 @@ namespace test_dat_key grn::dat::UInt32 buf[16]; const grn::dat::Key &key = grn::dat::Key::create(buf, 123, "groonga", 7); - cut_assert(key.str() == grn::dat::String("groonga")); + cppcut_assert_equal(key.str(), grn::dat::String("groonga")); cppcut_assert_equal(key.id(), static_cast<grn::dat::UInt32>(123)); cppcut_assert_equal(key.length(), static_cast<grn::dat::UInt32>(7)); cppcut_assert_equal(std::memcmp(key.ptr(), "groonga", 7), 0); Modified: test/unit/core/dat/test-node.cpp (+26 -10) =================================================================== --- test/unit/core/dat/test-node.cpp 2011-11-10 05:55:07 +0000 (896d539) +++ test/unit/core/dat/test-node.cpp 2011-11-10 06:29:51 +0000 (0c10efa) @@ -24,7 +24,7 @@ #include <iostream> -namespace +namespace cut { std::ostream &operator<<(std::ostream &stream, const grn::dat::Base &base) { @@ -35,6 +35,23 @@ namespace } return stream; } + + std::ostream &operator<<(std::ostream &stream, const grn::dat::Check &check) + { + if (check.is_offset()) { + stream << "offset: " << check.except_is_offset() << "; "; + } else { + stream << "not offset: " << check.except_is_offset() << "; "; + } + + if (check.is_phantom()) { + stream << "phantom: " << check.next() << ", " << check.prev(); + } else { + stream << "non-phantom: " << check.label() + << ", " << check.child() << ", " << check.sibling(); + } + return stream; + } } namespace test_dat_node @@ -44,18 +61,17 @@ namespace test_dat_node grn::dat::Node node; grn::dat::Base base; - cut_assert(node.base() == base); cppcut_assert_equal(node.base(), base); node.set_key_pos(100); base.set_key_pos(100); - cut_assert(node.base() == base); + cppcut_assert_equal(node.base(), base); cppcut_assert_equal(node.is_linker(), base.is_linker()); cppcut_assert_equal(node.key_pos(), base.key_pos()); node.set_offset(1000); base.set_offset(1000); - cut_assert(node.base() == base); + cppcut_assert_equal(node.base(), base); cppcut_assert_equal(node.is_linker(), base.is_linker()); cppcut_assert_equal(node.offset(), base.offset()); } @@ -65,31 +81,31 @@ namespace test_dat_node grn::dat::Node node; grn::dat::Check check; - cut_assert(node.check() == check); + cppcut_assert_equal(node.check(), check); node.set_is_offset(true); check.set_is_offset(true); - cut_assert(node.check() == check); + cppcut_assert_equal(node.check(), check); cppcut_assert_equal(node.is_offset(), check.is_offset()); node.set_offset(grn::dat::INVALID_OFFSET); node.set_is_phantom(true); check.set_is_phantom(true); - cut_assert(node.check() == check); + cppcut_assert_equal(node.check(), check); cppcut_assert_equal(node.is_phantom(), check.is_phantom()); node.set_next(101); node.set_prev(99); check.set_next(101); check.set_prev(99); - cut_assert(node.check() == check); + cppcut_assert_equal(node.check(), check); cppcut_assert_equal(node.next(), check.next()); cppcut_assert_equal(node.prev(), check.prev()); node.set_is_phantom(false); check.set_is_phantom(false); - cut_assert(node.check() == check); + cppcut_assert_equal(node.check(), check); cppcut_assert_equal(node.is_phantom(), check.is_phantom()); cppcut_assert_equal(node.label(), check.label()); cppcut_assert_equal(node.child(), check.child()); @@ -97,7 +113,7 @@ namespace test_dat_node node.set_label('a'); check.set_label('a'); - cut_assert(node.check() == check); + cppcut_assert_equal(node.check(), check); cppcut_assert_equal(node.label(), check.label()); } } Modified: test/unit/core/dat/test-string.cpp (+11 -3) =================================================================== --- test/unit/core/dat/test-string.cpp 2011-11-10 05:55:07 +0000 (84b02df) +++ test/unit/core/dat/test-string.cpp 2011-11-10 06:29:51 +0000 (b5fe8bb) @@ -22,6 +22,14 @@ #include <grn-assertions.h> #include <dat/string.hpp> +namespace cut +{ + std::ostream &operator<<(std::ostream &stream, const grn::dat::String &str) + { + return stream.write(static_cast<const char *>(str.ptr()), str.length()); + } +} + namespace test_dat_string { void test_empty_string(void) @@ -85,9 +93,9 @@ namespace test_dat_string { const grn::dat::String str("apple"); - cut_assert(str.substr(3) == grn::dat::String("le")); - cut_assert(str.substr(0, 3) == grn::dat::String("app")); - cut_assert(str.substr(1, 3) == grn::dat::String("ppl")); + cppcut_assert_equal(str.substr(3), grn::dat::String("le")); + cppcut_assert_equal(str.substr(0, 3), grn::dat::String("app")); + cppcut_assert_equal(str.substr(1, 3), grn::dat::String("ppl")); } void test_compare(void)