diff --git a/dlib/test/CMakeLists.txt b/dlib/test/CMakeLists.txt index e02c14722..003c747df 100644 --- a/dlib/test/CMakeLists.txt +++ b/dlib/test/CMakeLists.txt @@ -101,6 +101,7 @@ set (tests sockets2.cpp sockets.cpp sockstreambuf.cpp + sparse_vector.cpp stack.cpp static_map.cpp static_set.cpp diff --git a/dlib/test/makefile b/dlib/test/makefile index a81aa0e0e..6ff885f21 100644 --- a/dlib/test/makefile +++ b/dlib/test/makefile @@ -116,6 +116,7 @@ SRC += smart_pointers.cpp SRC += sockets2.cpp SRC += sockets.cpp SRC += sockstreambuf.cpp +SRC += sparse_vector.cpp SRC += stack.cpp SRC += static_map.cpp SRC += static_set.cpp diff --git a/dlib/test/sparse_vector.cpp b/dlib/test/sparse_vector.cpp new file mode 100644 index 000000000..ebe3a071d --- /dev/null +++ b/dlib/test/sparse_vector.cpp @@ -0,0 +1,67 @@ +// Copyright (C) 2012 Davis E. King (davis@dlib.net) +// License: Boost Software License See LICENSE.txt for the full license. + +#include "tester.h" +#include +#include +#include +#include +#include +#include + +namespace +{ + using namespace test; + using namespace dlib; + using namespace std; + using namespace dlib::sparse_vector; + dlib::logger dlog("test.sparse_vector"); + + + class sparse_vector_tester : public tester + { + public: + sparse_vector_tester ( + ) : + tester ( + "test_sparse_vector", // the command line argument name for this test + "Run tests on the sparse_vector routines.", // the command line argument description + 0 // the number of command line arguments for this test + ) + { + } + + + void perform_test ( + ) + { + std::map v; + v[4] = 8; + v[2] = -4; + v[9] = 10; + + DLIB_TEST(max(v) == 10); + DLIB_TEST(min(v) == -4); + + v.clear(); + v[4] = 8; + v[9] = 10; + DLIB_TEST(max(v) == 10); + DLIB_TEST(min(v) == 0); + + + v.clear(); + v[4] = -9; + v[9] = -4; + DLIB_TEST(max(v) == 0); + DLIB_TEST(min(v) == -9); + + } + }; + + sparse_vector_tester a; + +} + + +