summaryrefslogtreecommitdiff
path: root/test/bytesizeparsertest.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2018-06-16 18:05:00 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2018-06-16 18:15:59 +0200
commit2abc107b24f73b8c4664189c34196d9a27a3e339 (patch)
treeb7067a45f7294dbd143c410bdfb690157c976e3c /test/bytesizeparsertest.cc
parente694a23ab28686ecc0635c2ac8c625e743b89a3b (diff)
Port the rest of the unittests to DGUnit and remove the CppUnit dependency.
Diffstat (limited to 'test/bytesizeparsertest.cc')
-rw-r--r--test/bytesizeparsertest.cc61
1 files changed, 29 insertions, 32 deletions
diff --git a/test/bytesizeparsertest.cc b/test/bytesizeparsertest.cc
index e4776fe..ea082e2 100644
--- a/test/bytesizeparsertest.cc
+++ b/test/bytesizeparsertest.cc
@@ -24,25 +24,22 @@
* along with DrumGizmo; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include <cppunit/extensions/HelperMacros.h>
+#include "dgunit.h"
#include "bytesizeparser.h"
class ByteSizeParserTest
- : public CppUnit::TestFixture
+ : public DGUnit
{
- CPPUNIT_TEST_SUITE(ByteSizeParserTest);
- CPPUNIT_TEST(suffixTest);
- CPPUNIT_TEST(falseSuffixTest);
- CPPUNIT_TEST(falseNumberTest);
- CPPUNIT_TEST(tooBigNumberTest);
- CPPUNIT_TEST_SUITE_END();
-
public:
- void setUp() {}
-
- void tearDown() {}
+ ByteSizeParserTest()
+ {
+ DGUNIT_TEST(ByteSizeParserTest::suffixTest);
+ DGUNIT_TEST(ByteSizeParserTest::falseSuffixTest);
+ DGUNIT_TEST(ByteSizeParserTest::falseNumberTest);
+ DGUNIT_TEST(ByteSizeParserTest::tooBigNumberTest);
+ }
void suffixTest()
{
@@ -50,78 +47,78 @@ public:
std::size_t kilo = 1024, mega = kilo * 1024, giga = mega * 1024;
computed_size = byteSizeParser("3");
expected_size = 3;
- CPPUNIT_ASSERT_EQUAL(expected_size, computed_size);
+ DGUNIT_ASSERT_EQUAL(expected_size, computed_size);
computed_size = byteSizeParser("3k");
expected_size = 3 * kilo;
- CPPUNIT_ASSERT_EQUAL(expected_size, computed_size);
+ DGUNIT_ASSERT_EQUAL(expected_size, computed_size);
computed_size = byteSizeParser("3M");
expected_size = 3 * mega;
- CPPUNIT_ASSERT_EQUAL(expected_size, computed_size);
+ DGUNIT_ASSERT_EQUAL(expected_size, computed_size);
computed_size = byteSizeParser("3G");
expected_size = 3 * giga;
- CPPUNIT_ASSERT_EQUAL(expected_size, computed_size);
+ DGUNIT_ASSERT_EQUAL(expected_size, computed_size);
}
void falseSuffixTest()
{
std::size_t computed_size, expected_size = 0;
computed_size = byteSizeParser("3K");
- CPPUNIT_ASSERT_EQUAL(expected_size, computed_size);
+ DGUNIT_ASSERT_EQUAL(expected_size, computed_size);
computed_size = byteSizeParser("3m");
- CPPUNIT_ASSERT_EQUAL(expected_size, computed_size);
+ DGUNIT_ASSERT_EQUAL(expected_size, computed_size);
computed_size = byteSizeParser("3g");
- CPPUNIT_ASSERT_EQUAL(expected_size, computed_size);
+ DGUNIT_ASSERT_EQUAL(expected_size, computed_size);
computed_size = byteSizeParser("3ddDD");
- CPPUNIT_ASSERT_EQUAL(expected_size, computed_size);
+ DGUNIT_ASSERT_EQUAL(expected_size, computed_size);
}
void falseNumberTest()
{
std::size_t computed_size, expected_size = 0;
computed_size = byteSizeParser("K3k");
- CPPUNIT_ASSERT_EQUAL(expected_size, computed_size);
+ DGUNIT_ASSERT_EQUAL(expected_size, computed_size);
computed_size = byteSizeParser("-3");
- CPPUNIT_ASSERT_EQUAL(expected_size, computed_size);
+ DGUNIT_ASSERT_EQUAL(expected_size, computed_size);
computed_size = byteSizeParser("-3k");
- CPPUNIT_ASSERT_EQUAL(expected_size, computed_size);
+ DGUNIT_ASSERT_EQUAL(expected_size, computed_size);
computed_size = byteSizeParser("-3M");
- CPPUNIT_ASSERT_EQUAL(expected_size, computed_size);
+ DGUNIT_ASSERT_EQUAL(expected_size, computed_size);
computed_size = byteSizeParser("-3G");
- CPPUNIT_ASSERT_EQUAL(expected_size, computed_size);
+ DGUNIT_ASSERT_EQUAL(expected_size, computed_size);
computed_size = byteSizeParser("3-");
- CPPUNIT_ASSERT_EQUAL(expected_size, computed_size);
+ DGUNIT_ASSERT_EQUAL(expected_size, computed_size);
computed_size = byteSizeParser("3-k");
- CPPUNIT_ASSERT_EQUAL(expected_size, computed_size);
+ DGUNIT_ASSERT_EQUAL(expected_size, computed_size);
computed_size = byteSizeParser("k-3");
- CPPUNIT_ASSERT_EQUAL(expected_size, computed_size);
+ DGUNIT_ASSERT_EQUAL(expected_size, computed_size);
computed_size = byteSizeParser("3-1");
- CPPUNIT_ASSERT_EQUAL(expected_size, computed_size);
+ DGUNIT_ASSERT_EQUAL(expected_size, computed_size);
computed_size = byteSizeParser(" -3");
- CPPUNIT_ASSERT_EQUAL(expected_size, computed_size);
+ DGUNIT_ASSERT_EQUAL(expected_size, computed_size);
}
void tooBigNumberTest()
{
std::size_t computed_size, expected_size = 0;
computed_size = byteSizeParser("999999999999999999999999999999999999G");
- CPPUNIT_ASSERT_EQUAL(expected_size, computed_size);
+ DGUNIT_ASSERT_EQUAL(expected_size, computed_size);
}
};
// Registers the fixture into the 'registry'
-CPPUNIT_TEST_SUITE_REGISTRATION(ByteSizeParserTest);
+static ByteSizeParserTest test;