summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--statistics.cpp4
-rw-r--r--statistics.h8
-rw-r--r--tests/test-auth.cpp15
3 files changed, 20 insertions, 7 deletions
diff --git a/statistics.cpp b/statistics.cpp
index 6138cca..1d67bfd 100644
--- a/statistics.cpp
+++ b/statistics.cpp
@@ -17,7 +17,7 @@ void Statistics::load()
std::cout << "Loading statistics..." << std::endl;
std::ifstream file{statsfilepath, std::ios::in | std::ios::binary};
if (file.is_open()) {
- Serialization::IArchive archive{file};
+ Reichwein::Serialization::IArchive archive{file};
archive >> mBins;
} else {
@@ -34,7 +34,7 @@ void Statistics::save()
std::cout << "Saving statistics..." << std::endl;
std::ofstream file{statsfilepath, std::ios::out | std::ios::binary | std::ios::trunc};
if (file.is_open()) {
- Serialization::OArchive archive{file};
+ Reichwein::Serialization::OArchive archive{file};
archive << mBins;
} else {
diff --git a/statistics.h b/statistics.h
index c38ef66..a8b4854 100644
--- a/statistics.h
+++ b/statistics.h
@@ -78,10 +78,10 @@ public:
};
// Serialization and Deserialization as free functions
-namespace Serialization {
+namespace Reichwein::Serialization {
template <class T>
-Serialization::OArchive& operator& (Serialization::OArchive& ar, std::deque<T>& deque)
+Reichwein::Serialization::OArchive& operator& (Reichwein::Serialization::OArchive& ar, std::deque<T>& deque)
{
uint64_t size { deque.size() };
@@ -95,7 +95,7 @@ Serialization::OArchive& operator& (Serialization::OArchive& ar, std::deque<T>&
}
template <class T>
-Serialization::IArchive& operator& (Serialization::IArchive& ar, std::deque<T>& deque)
+Reichwein::Serialization::IArchive& operator& (Reichwein::Serialization::IArchive& ar, std::deque<T>& deque)
{
uint64_t size {};
@@ -112,4 +112,4 @@ Serialization::IArchive& operator& (Serialization::IArchive& ar, std::deque<T>&
return ar;
}
-}
+} // namespace
diff --git a/tests/test-auth.cpp b/tests/test-auth.cpp
index 7948a0a..8397b35 100644
--- a/tests/test-auth.cpp
+++ b/tests/test-auth.cpp
@@ -22,7 +22,20 @@ public:
void teardown(){}
};
-BOOST_FIXTURE_TEST_CASE(auth, AuthFixture)
+BOOST_FIXTURE_TEST_CASE(generate, AuthFixture)
{
+ std::string pw0 {Auth::generate("")};
+ BOOST_CHECK_GT(pw0.size(), 0);
+ std::string pw1 {Auth::generate("abc")};
+ BOOST_CHECK_GT(pw1.size(), 0);
+
+ BOOST_CHECK_NE(pw0, pw1);
}
+BOOST_FIXTURE_TEST_CASE(validate, AuthFixture)
+{
+ BOOST_CHECK(Auth::validate("t5MMkLQXzYkdw", "abc"));
+
+ BOOST_CHECK(!Auth::validate("abc", "abc"));
+ BOOST_CHECK(!Auth::validate("t5MNkLQXzYkdw", "abc"));
+}