[gnote] Convert GnoteSyncClient test into unit test



commit 626239a9770e8c58bbe09b5b3c6f45c37a402dbb
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sat Jan 28 17:32:20 2017 +0200

    Convert GnoteSyncClient test into unit test

 src/Makefile.am                                    |   19 +++----------
 .../gnotesyncclientutests.cpp}                     |   28 +++++++++++--------
 2 files changed, 21 insertions(+), 26 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 64a020e..dc3a52c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -23,21 +23,22 @@ GNOTE_LIBS = libgnote.la $(LIBGNOTE_LIBS)
 
 lib_LTLIBRARIES = libgnote.la
 bin_PROGRAMS = gnote
-check_PROGRAMS = gnotesyncclienttest
-TESTS = gnotesyncclienttest
 
 if HAVE_UNITTESTCPP
-check_PROGRAMS += gnoteunittests
-TESTS += gnoteunittests
+check_PROGRAMS = gnoteunittests
+TESTS = gnoteunittests
 
 gnoteunittests_SOURCES = \
+       synchronization/gnotesyncclient.hpp synchronization/gnotesyncclient.cpp \
        test/runner.cpp \
        test/testnote.cpp test/testnote.hpp \
        test/testnotemanager.cpp test/testnotemanager.hpp \
+       test/testsyncclient.hpp test/testsyncclient.cpp \
        test/testtagmanager.cpp test/testtagmanager.hpp \
        test/unit/datetimeutests.cpp \
        test/unit/filesutests.cpp \
        test/unit/fileinfoutests.cpp \
+       test/unit/gnotesyncclientutests.cpp \
        test/unit/noteutests.cpp \
        test/unit/notemanagerutests.cpp \
        test/unit/stringutests.cpp \
@@ -49,16 +50,6 @@ gnoteunittests_LDADD = libgnote.la @UNITTESTCPP_LIBS@
 endif
 
 
-gnotesyncclienttest_SOURCES = test/gnotesyncclienttest.cpp \
-       test/testnote.cpp test/testnote.hpp \
-       test/testnotemanager.cpp test/testnotemanager.hpp \
-       test/testsyncclient.hpp test/testsyncclient.cpp \
-       test/testtagmanager.cpp test/testtagmanager.hpp \
-       synchronization/gnotesyncclient.hpp synchronization/gnotesyncclient.cpp \
-       $(NULL)
-gnotesyncclienttest_LDADD = $(GNOTE_LIBS)
-
-
 SUBDIRS += dbus
 DBUS_SOURCES=remotecontrolproxy.hpp remotecontrolproxy.cpp \
        dbus/remotecontrol.hpp dbus/remotecontrol.cpp \
diff --git a/src/test/gnotesyncclienttest.cpp b/src/test/unit/gnotesyncclientutests.cpp
similarity index 81%
rename from src/test/gnotesyncclienttest.cpp
rename to src/test/unit/gnotesyncclientutests.cpp
index 10f4058..89f6c7a 100644
--- a/src/test/gnotesyncclienttest.cpp
+++ b/src/test/unit/gnotesyncclientutests.cpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2014 Aurimas Cernius
+ * Copyright (C) 2017 Aurimas Cernius
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -20,13 +20,16 @@
 
 #include <cstdio>
 
-#include <boost/test/minimal.hpp>
+#include <UnitTest++/UnitTest++.h>
 
-#include "testnotemanager.hpp"
-#include "testsyncclient.hpp"
-#include "testtagmanager.hpp"
+#include "test/testnotemanager.hpp"
+#include "test/testsyncclient.hpp"
+#include "test/testtagmanager.hpp"
 
 
+SUITE(GnoteSyncClient)
+{
+
 const char *TEST_MANIFEST =
   "<manifest>"
   "  <last-sync-date>2014-04-21T20:13:24.711343Z</last-sync-date>"
@@ -60,7 +63,7 @@ std::string create_manifest()
 }
 
 
-int test_main(int /*argc*/, char ** /*argv*/)
+TEST(manifest_parsing)
 {
   std::string test_manifest = create_manifest();
   
@@ -71,17 +74,18 @@ int test_main(int /*argc*/, char ** /*argv*/)
   client.reparse();
 
   sharp::DateTime sync_date(sharp::DateTime::from_iso8601("2014-04-21T20:13:24.711343Z"));
-  BOOST_CHECK(client.last_sync_date() == sync_date);
-  BOOST_CHECK(client.last_synchronized_revision() == 0);
-  BOOST_CHECK(client.associated_server_id() == "38afddc2-9ce8-46ba-b106-baf3916c74b8");
-  BOOST_CHECK(client.deleted_note_titles().size() == 3);
+  CHECK(client.last_sync_date() == sync_date);
+  CHECK_EQUAL(0, client.last_synchronized_revision());
+  CHECK_EQUAL("38afddc2-9ce8-46ba-b106-baf3916c74b8", client.associated_server_id());
+  CHECK_EQUAL(3, client.deleted_note_titles().size());
 
   gnote::NoteBase::Ptr note = manager.create("test");
   client.set_revision(note, 1);
   client.reparse();
-  BOOST_CHECK(client.get_revision(note) == 1);
+  CHECK_EQUAL(1, client.get_revision(note));
 
   std::remove(test_manifest.c_str());
-  return 0;
+}
+
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]