Alexander Afanasyev | bf2b436 | 2012-03-12 23:55:09 -0700 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2012 University of California, Los Angeles |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation; |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | * |
| 18 | * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu> |
| 19 | * 卞超轶 Chaoyi Bian <bcy@pku.edu.cn> |
| 20 | * Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 21 | */ |
| 22 | |
| 23 | #include <boost/test/unit_test.hpp> |
| 24 | #include <boost/test/output_test_stream.hpp> |
| 25 | #include <map> |
| 26 | using boost::test_tools::output_test_stream; |
| 27 | |
| 28 | #include <boost/make_shared.hpp> |
| 29 | |
| 30 | #include "../model/sync-ccnx-wrapper.h" |
| 31 | #include "../model/sync-logic.h" |
| 32 | #include "../model/sync-seq-no.h" |
| 33 | |
| 34 | using namespace std; |
| 35 | using namespace boost; |
| 36 | using namespace Sync; |
| 37 | |
| 38 | struct Handler |
| 39 | { |
| 40 | string instance; |
| 41 | |
| 42 | Handler (const string &_instance) |
| 43 | : instance (_instance) |
| 44 | { |
| 45 | } |
| 46 | |
| 47 | void onUpdate (const string &p/*prefix*/, const SeqNo &seq/*newSeq*/, const SeqNo &/*oldSeq*/) |
| 48 | { |
| 49 | cout << instance << "\t" << p << ": " << seq << endl; |
| 50 | } |
| 51 | |
| 52 | void onRemove (const string &p/*prefix*/) |
| 53 | { |
| 54 | cout << instance << "\t" << p << endl; |
| 55 | } |
| 56 | }; |
| 57 | |
| 58 | BOOST_AUTO_TEST_CASE (SyncLogicTest) |
| 59 | { |
| 60 | Handler h1 ("1"), h2 ("2"); |
| 61 | |
Alexander Afanasyev | 44ab222 | 2012-03-13 00:09:29 -0700 | [diff] [blame] | 62 | SyncLogic l1 ("/bcast", bind (&Handler::onUpdate, &h1, _1, _2, _3), bind (&Handler::onRemove, &h1, _1)); |
| 63 | SyncLogic L2 ("/bcast", bind (&Handler::onUpdate, &h2, _1, _2, _3), bind (&Handler::onRemove, &h2, _1)); |
Alexander Afanasyev | bf2b436 | 2012-03-12 23:55:09 -0700 | [diff] [blame] | 64 | |
| 65 | sleep (10); |
| 66 | // l1. |
| 67 | } |