aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-15 22:04:17 +0200
committerMax Kellermann <max@duempel.org>2013-10-15 22:47:39 +0200
commit509f8dab8946cfc311def89f62352c0881e73348 (patch)
tree913fbb714704bcffc0ca6b8f44cdfb293ec9ee24 /test
parent77429b6dd35e23efac92630bab35d935b9496345 (diff)
downloadmpd-509f8dab8946cfc311def89f62352c0881e73348.tar.gz
mpd-509f8dab8946cfc311def89f62352c0881e73348.tar.xz
mpd-509f8dab8946cfc311def89f62352c0881e73348.zip
Util/Macros: replacement for GLib's G_N_ELEMENTS()
Diffstat (limited to 'test')
-rw-r--r--test/test_byte_reverse.c17
-rw-r--r--test/test_queue_priority.cxx7
2 files changed, 13 insertions, 11 deletions
diff --git a/test/test_byte_reverse.c b/test/test_byte_reverse.c
index 08a107622..1ab787772 100644
--- a/test/test_byte_reverse.c
+++ b/test/test_byte_reverse.c
@@ -18,6 +18,7 @@
*/
#include "util/byte_reverse.h"
+#include "util/Macros.hxx"
#include <glib.h>
@@ -26,10 +27,10 @@ test_byte_reverse_2(void)
{
static const char src[] = "123456";
static const char result[] = "214365";
- static uint8_t dest[G_N_ELEMENTS(src)];
+ static uint8_t dest[ARRAY_SIZE(src)];
reverse_bytes(dest, (const uint8_t *)src,
- (const uint8_t *)(src + G_N_ELEMENTS(src) - 1), 2);
+ (const uint8_t *)(src + ARRAY_SIZE(src) - 1), 2);
g_assert_cmpstr((const char *)dest, ==, result);
}
@@ -38,10 +39,10 @@ test_byte_reverse_3(void)
{
static const char src[] = "123456";
static const char result[] = "321654";
- static uint8_t dest[G_N_ELEMENTS(src)];
+ static uint8_t dest[ARRAY_SIZE(src)];
reverse_bytes(dest, (const uint8_t *)src,
- (const uint8_t *)(src + G_N_ELEMENTS(src) - 1), 3);
+ (const uint8_t *)(src + ARRAY_SIZE(src) - 1), 3);
g_assert_cmpstr((const char *)dest, ==, result);
}
@@ -50,10 +51,10 @@ test_byte_reverse_4(void)
{
static const char src[] = "12345678";
static const char result[] = "43218765";
- static uint8_t dest[G_N_ELEMENTS(src)];
+ static uint8_t dest[ARRAY_SIZE(src)];
reverse_bytes(dest, (const uint8_t *)src,
- (const uint8_t *)(src + G_N_ELEMENTS(src) - 1), 4);
+ (const uint8_t *)(src + ARRAY_SIZE(src) - 1), 4);
g_assert_cmpstr((const char *)dest, ==, result);
}
@@ -62,10 +63,10 @@ test_byte_reverse_5(void)
{
static const char src[] = "1234567890";
static const char result[] = "5432109876";
- static uint8_t dest[G_N_ELEMENTS(src)];
+ static uint8_t dest[ARRAY_SIZE(src)];
reverse_bytes(dest, (const uint8_t *)src,
- (const uint8_t *)(src + G_N_ELEMENTS(src) - 1), 5);
+ (const uint8_t *)(src + ARRAY_SIZE(src) - 1), 5);
g_assert_cmpstr((const char *)dest, ==, result);
}
diff --git a/test/test_queue_priority.cxx b/test/test_queue_priority.cxx
index 2e544253d..11896978e 100644
--- a/test/test_queue_priority.cxx
+++ b/test/test_queue_priority.cxx
@@ -2,6 +2,7 @@
#include "Queue.hxx"
#include "Song.hxx"
#include "Directory.hxx"
+#include "util/Macros.hxx"
#include <glib.h>
@@ -54,10 +55,10 @@ main(gcc_unused int argc, gcc_unused char **argv)
struct queue queue(32);
- for (unsigned i = 0; i < G_N_ELEMENTS(songs); ++i)
+ for (unsigned i = 0; i < ARRAY_SIZE(songs); ++i)
queue.Append(&songs[i], 0);
- assert(queue.GetLength() == G_N_ELEMENTS(songs));
+ assert(queue.GetLength() == ARRAY_SIZE(songs));
/* priority=10 for 4 items */
@@ -75,7 +76,7 @@ main(gcc_unused int argc, gcc_unused char **argv)
assert(queue.PositionToOrder(i) < 4);
}
- for (unsigned i = 8; i < G_N_ELEMENTS(songs); ++i) {
+ for (unsigned i = 8; i < ARRAY_SIZE(songs); ++i) {
assert(queue.PositionToOrder(i) >= 4);
}