aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-20 00:14:29 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-20 16:20:41 +0000
commit77bcfa0f5b9b75d80d51639a65d662de84251d89 (patch)
treee302621e8e0390f4ac2847b97ea729bfe019727c
parentba4ebf7511fe5e1caa2de070f5c785d59f956e30 (diff)
downloadpaludis-77bcfa0f5b9b75d80d51639a65d662de84251d89.tar.gz
paludis-77bcfa0f5b9b75d80d51639a65d662de84251d89.tar.xz
gtest more
-rw-r--r--paludis/util/byte_swap_TEST.cc82
-rw-r--r--paludis/util/files.m42
2 files changed, 39 insertions, 45 deletions
diff --git a/paludis/util/byte_swap_TEST.cc b/paludis/util/byte_swap_TEST.cc
index aad78b9..99a4465 100644
--- a/paludis/util/byte_swap_TEST.cc
+++ b/paludis/util/byte_swap_TEST.cc
@@ -2,6 +2,7 @@
/*
* Copyright (c) 2007 David Leverton
+ * Copyright (c) 2011 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -17,62 +18,55 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "byte_swap.hh"
-
-#include <test/test_runner.hh>
-#include <test/test_framework.hh>
+#include <paludis/util/byte_swap.hh>
#include <stdint.h>
-using namespace test;
+#include <gtest/gtest.h>
+
using namespace paludis;
-namespace test_cases
+namespace
{
- struct ByteSwapTest : TestCase
+ int64_t int64(int64_t a, int64_t b)
{
- ByteSwapTest() : TestCase("byte_swap") {}
-
- int64_t int64(int64_t a, int64_t b)
- {
- return (a << 32) | b;
- }
+ return (a << 32) | b;
+ }
- uint64_t uint64(uint64_t a, uint64_t b)
- {
- return (a << 32) | b;
- }
+ uint64_t uint64(uint64_t a, uint64_t b)
+ {
+ return (a << 32) | b;
+ }
+}
-#define CHECK(T, X, Y) do { TEST_CHECK_EQUAL(byte_swap(T(X)), T(Y)); TEST_CHECK_EQUAL(byte_swap(T(Y)), T(X)); } while (0)
+#define CHECK(T, X, Y) do { EXPECT_EQ(T(Y), byte_swap(T(X))); EXPECT_EQ(T(X), byte_swap(T(Y))); } while (0)
- void run()
- {
- CHECK(int8_t, 0x42, 0x42);
- CHECK(uint8_t, 0x42, 0x42);
- CHECK(int8_t, 0x92, 0x92);
- CHECK(uint8_t, 0x92, 0x92);
+TEST(ByteSwap, Works)
+{
+ CHECK(int8_t, 0x42, 0x42);
+ CHECK(uint8_t, 0x42, 0x42);
+ CHECK(int8_t, 0x92, 0x92);
+ CHECK(uint8_t, 0x92, 0x92);
- CHECK(int16_t, 0x4218, 0x1842);
- CHECK(uint16_t, 0x4218, 0x1842);
- CHECK(int16_t, 0x4298, 0x9842);
- CHECK(uint16_t, 0x4298, 0x9842);
- CHECK(int16_t, 0x9218, 0x1892);
- CHECK(uint16_t, 0x9218, 0x1892);
+ CHECK(int16_t, 0x4218, 0x1842);
+ CHECK(uint16_t, 0x4218, 0x1842);
+ CHECK(int16_t, 0x4298, 0x9842);
+ CHECK(uint16_t, 0x4298, 0x9842);
+ CHECK(int16_t, 0x9218, 0x1892);
+ CHECK(uint16_t, 0x9218, 0x1892);
- CHECK(int32_t, 0x4218A43F, 0x3FA41842);
- CHECK(uint32_t, 0x4218A43F, 0x3FA41842);
- CHECK(int32_t, 0x4218A4CF, 0xCFA41842);
- CHECK(uint32_t, 0x4218A4CF, 0xCFA41842);
- CHECK(int32_t, 0x9218A43F, 0x3FA41892);
- CHECK(uint32_t, 0x9218A43F, 0x3FA41892);
+ CHECK(int32_t, 0x4218A43F, 0x3FA41842);
+ CHECK(uint32_t, 0x4218A43F, 0x3FA41842);
+ CHECK(int32_t, 0x4218A4CF, 0xCFA41842);
+ CHECK(uint32_t, 0x4218A4CF, 0xCFA41842);
+ CHECK(int32_t, 0x9218A43F, 0x3FA41892);
+ CHECK(uint32_t, 0x9218A43F, 0x3FA41892);
- CHECK(int64_t, int64(0x42A57104, 0x32D61259), int64(0x5912D632, 0x0471A542));
- CHECK(uint64_t, uint64(0x42A57104, 0x32D61259), uint64(0x5912D632, 0x0471A542));
- CHECK(int64_t, int64(0x42A57104, 0x32D612E9), int64(0xE912D632, 0x0471A542));
- CHECK(uint64_t, uint64(0x42A57104, 0x32D612E9), uint64(0xE912D632, 0x0471A542));
- CHECK(int64_t, int64(0x92A57104, 0x32D61259), int64(0x5912D632, 0x0471A592));
- CHECK(uint64_t, uint64(0x92A57104, 0x32D61259), uint64(0x5912D632, 0x0471A592));
- }
- } byte_swap_test;
+ CHECK(int64_t, int64(0x42A57104, 0x32D61259), int64(0x5912D632, 0x0471A542));
+ CHECK(uint64_t, uint64(0x42A57104, 0x32D61259), uint64(0x5912D632, 0x0471A542));
+ CHECK(int64_t, int64(0x42A57104, 0x32D612E9), int64(0xE912D632, 0x0471A542));
+ CHECK(uint64_t, uint64(0x42A57104, 0x32D612E9), uint64(0xE912D632, 0x0471A542));
+ CHECK(int64_t, int64(0x92A57104, 0x32D61259), int64(0x5912D632, 0x0471A592));
+ CHECK(uint64_t, uint64(0x92A57104, 0x32D61259), uint64(0x5912D632, 0x0471A592));
}
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index 80f12dd..4a303dd 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -13,7 +13,7 @@ add(`action_queue', `hh', `cc', `gtest')
add(`active_object_ptr', `hh', `cc', `fwd', `gtest')
add(`attributes', `hh')
add(`buffer_output_stream', `hh', `cc', `fwd', `gtest')
-add(`byte_swap', `hh', `test')
+add(`byte_swap', `hh', `gtest')
add(`channel', `hh', `cc')
add(`checked_delete', `hh')
add(`clone', `hh', `impl')