# # # add_file "roster_tests.hh" # content [2a7c9e87be949541081a52fe18aa732a544397d6] # # patch "Makefile.am" # from [789e3045b844e413fabcc6180e5898ed812ac3c5] # to [f9f47a97e59ee658ae1830700e403bd981c8a156] # # patch "merge_roster.cc" # from [acfb17d85ecf0a9691ebb8833817b43750b5725d] # to [eb800b3f9442d5f00790e1f92d1b560b23714a2c] # # patch "roster.cc" # from [2ffc18c20c2e53c540b7312a125681d60a6778f9] # to [fdcabef3294b34d9816a3da0d2da8e2d90befdb2] # # patch "roster.hh" # from [ef1b40df5043af074ee007ea5efdb726e1b4112f] # to [90a95971b06f5586a5bd9c76dc701c643280bf87] # # patch "roster_delta.cc" # from [f05705a1dbf00dbb77d4f13153a26da957a0c9a9] # to [f21967cc9f37298083c2a384d167e325e2fa197d] # # patch "roster_delta.hh" # from [1c64a4f5d5b9c474f5709f108357269fb2c934d9] # to [1cbd73f46a1aa4864ae5b172b67662e8088b810d] # ============================================================ --- roster_tests.hh 2a7c9e87be949541081a52fe18aa732a544397d6 +++ roster_tests.hh 2a7c9e87be949541081a52fe18aa732a544397d6 @@ -0,0 +1,36 @@ +#ifndef __ROSTER_TESTS_HH__ +#define __ROSTER_TESTS_HH__ + +// Copyright (C) 2008 Stephen Leake +// Copyright (C) 2005 Nathaniel Smith +// +// This program is made available under the GNU GPL version 2.0 or +// greater. See the accompanying file COPYING for details. +// +// This program is distributed WITHOUT ANY WARRANTY; without even the +// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. + +// Interfaces among roster.cc, merge_roster.cc, and roster_delta.cc +// used exclusively for testing. + +struct testing_node_id_source + : public node_id_source +{ + testing_node_id_source(); + virtual node_id next(); + node_id curr; +}; + +void test_roster_delta_on(roster_t const & a, marking_map const & a_marking, + roster_t const & b, marking_map const & b_marking); + +// Local Variables: +// mode: C++ +// fill-column: 76 +// c-file-style: "gnu" +// indent-tabs-mode: nil +// End: +// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s: + +#endif ============================================================ --- Makefile.am 789e3045b844e413fabcc6180e5898ed812ac3c5 +++ Makefile.am f9f47a97e59ee658ae1830700e403bd981c8a156 @@ -305,9 +305,9 @@ UNIT_TEST_SOURCES = \ string_queue.cc transforms.cc uri.cc vocab.cc xdelta.cc # these files do not contain unit tests, but are required for unit testing -# and must be recompiled for that purpose +# and are not used by the main program UNIT_TEST_SRC_SUPPORT = \ - roster_delta.cc randomizer.cc randomizer.hh unit_tests.cc + randomizer.cc randomizer.hh roster_tests.hh unit_tests.cc # these files do not contain unit tests; they are required for unit # testing, but can be used "as is" from the main build. (many of @@ -321,8 +321,8 @@ UNIT_TEST_OBJ_SUPPORT = \ mtn-lua.$(OBJEXT) mtn-lua_hooks.$(OBJEXT) \ mtn-merge_content.$(OBJEXT) mtn-merkle_tree.$(OBJEXT) \ mtn-pcrewrap.$(OBJEXT) mtn-project.$(OBJEXT) \ - mtn-sanity.$(OBJEXT) mtn-schema.$(OBJEXT) \ - mtn-migrate_schema.$(OBJEXT) \ + mtn-roster_delta.$(OBJEXT) mtn-sanity.$(OBJEXT) \ + mtn-schema.$(OBJEXT) mtn-migrate_schema.$(OBJEXT) \ mtn-specialized_lexical_cast.$(OBJEXT) mtn-ssh_agent.$(OBJEXT) \ mtn-std_hooks.$(OBJEXT) mtn-ui.$(OBJEXT) mtn-work.$(OBJEXT) \ mtn-migrate_work.$(OBJEXT) ============================================================ --- merge_roster.cc acfb17d85ecf0a9691ebb8833817b43750b5725d +++ merge_roster.cc eb800b3f9442d5f00790e1f92d1b560b23714a2c @@ -3113,6 +3113,7 @@ roster_merge(roster_t const & left_paren #include "unit_tests.hh" #include "constants.hh" #include "roster_delta.hh" +#include "roster_tests.hh" // cases for testing: // ============================================================ --- roster.cc 2ffc18c20c2e53c540b7312a125681d60a6778f9 +++ roster.cc fdcabef3294b34d9816a3da0d2da8e2d90befdb2 @@ -2722,8 +2722,8 @@ void calculate_ident(roster_t const & ro #include "sanity.hh" #include "constants.hh" #include "randomizer.hh" - #include "roster_delta.hh" +#include "roster_tests.hh" #include #include "lexical_cast.hh" @@ -2853,6 +2853,38 @@ static void } static void +spin(roster_t const & from, marking_map const & from_marking, + roster_t const & to, marking_map const & to_marking) +{ + MM(from); + MM(from_marking); + MM(to); + MM(to_marking); + roster_delta del; + MM(del); + delta_rosters(from, from_marking, to, to_marking, del); + + roster_t tmp(from); + MM(tmp); + marking_map tmp_marking(from_marking); + MM(tmp_marking); + apply_roster_delta(del, tmp, tmp_marking); + I(tmp == to); + I(tmp_marking == to_marking); + + roster_delta del2; + delta_rosters(from, from_marking, tmp, tmp_marking, del2); + I(del == del2); +} + +void test_roster_delta_on(roster_t const & a, marking_map const & a_marking, + roster_t const & b, marking_map const & b_marking) +{ + spin(a, a_marking, b, b_marking); + spin(b, b_marking, a, a_marking); +} + +static void tests_on_two_rosters(roster_t const & a, roster_t const & b, node_id_source & nis) { MM(a); ============================================================ --- roster.hh ef1b40df5043af074ee007ea5efdb726e1b4112f +++ roster.hh 90a95971b06f5586a5bd9c76dc701c643280bf87 @@ -478,18 +478,6 @@ inline marking_map const & parent_markin return *(i->second.second); } -#ifdef BUILD_UNIT_TESTS - -struct testing_node_id_source - : public node_id_source -{ - testing_node_id_source(); - virtual node_id next(); - node_id curr; -}; - -#endif // BUILD_UNIT_TESTS - // Local Variables: // mode: C++ // fill-column: 76 ============================================================ --- roster_delta.cc f05705a1dbf00dbb77d4f13153a26da957a0c9a9 +++ roster_delta.cc f21967cc9f37298083c2a384d167e325e2fa197d @@ -570,43 +570,6 @@ try_get_content_from_roster_delta(roster return false; } -#ifdef BUILD_UNIT_TESTS - -static void -spin(roster_t const & from, marking_map const & from_marking, - roster_t const & to, marking_map const & to_marking) -{ - MM(from); - MM(from_marking); - MM(to); - MM(to_marking); - roster_delta del; - MM(del); - delta_rosters(from, from_marking, to, to_marking, del); - - roster_t tmp(from); - MM(tmp); - marking_map tmp_marking(from_marking); - MM(tmp_marking); - apply_roster_delta(del, tmp, tmp_marking); - I(tmp == to); - I(tmp_marking == to_marking); - - roster_delta del2; - delta_rosters(from, from_marking, tmp, tmp_marking, del2); - I(del == del2); -} - -void test_roster_delta_on(roster_t const & a, marking_map const & a_marking, - roster_t const & b, marking_map const & b_marking) -{ - spin(a, a_marking, b, b_marking); - spin(b, b_marking, a, a_marking); -} - -#endif // BUILD_UNIT_TESTS - - // Local Variables: // mode: C++ // fill-column: 76 @@ -614,4 +577,3 @@ void test_roster_delta_on(roster_t const // indent-tabs-mode: nil // End: // vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s: - ============================================================ --- roster_delta.hh 1c64a4f5d5b9c474f5709f108357269fb2c934d9 +++ roster_delta.hh 1cbd73f46a1aa4864ae5b172b67662e8088b810d @@ -35,16 +35,6 @@ try_get_content_from_roster_delta(roster node_id const & nid, file_id & content); -#ifdef BUILD_UNIT_TESTS - -// instead of having elaborate tests here, we just export a function, and then -// let all the other code that already generates every strange and weird test -// case there is feed us our tests -void test_roster_delta_on(roster_t const & a, marking_map const & a_marking, - roster_t const & b, marking_map const & b_marking); - -#endif // BUILD_UNIT_TESTS - #endif // __ROSTER_DELTA_HH__