summaryrefslogtreecommitdiffstats
path: root/lib/x1000-installer/test/test_stream.c
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-12-19 21:46:52 +0000
committerAidan MacDonald <amachronic@protonmail.com>2022-12-23 19:54:18 +0000
commitba010851fafea3da0d0655b103158f0a9efe6406 (patch)
treebb26879ee1ac5e2d578948701b20c1bb33db14a9 /lib/x1000-installer/test/test_stream.c
parent6e794c9a2d9e91a926f70d0fcc66e255b0bdc221 (diff)
downloadrockbox-ba010851fa.tar.gz
rockbox-ba010851fa.zip
Remove lib/x1000-installer
Carrying this library is somewhat of a maintenance burden because some Rockbox APIs are mocked or duplicated in the test suite and thus need to be fixed up when refactoring. It's also unused & incomplete, so there's no good reason to keep it in tree any more. Change-Id: If39c62744b4edc0d81b1b6608ee5df69430e6581
Diffstat (limited to 'lib/x1000-installer/test/test_stream.c')
-rw-r--r--lib/x1000-installer/test/test_stream.c108
1 files changed, 0 insertions, 108 deletions
diff --git a/lib/x1000-installer/test/test_stream.c b/lib/x1000-installer/test/test_stream.c
deleted file mode 100644
index b4a5723b76..0000000000
--- a/lib/x1000-installer/test/test_stream.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2021 Aidan MacDonald
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-
-#include "test.h"
-#include "xf_stream.h"
-#include "xf_error.h"
-#include "file.h"
-#include <string.h>
-#include <stdbool.h>
-#include <stdio.h>
-
-#define TESTDATADIR "test/data/"
-#define TESTFILE_SHUFFLED TESTDATADIR "lines_shuffled.txt"
-#define TESTFILE_SORTED TESTDATADIR "lines_sorted.txt"
-
-const char line_string[] = "1234567890abcdefghijklmnopqrstuvwxyz";
-
-static int read_line_cb(int n, char* buf, void* arg)
-{
- int* max_n = (int*)arg;
- *max_n = n;
-
- T_ASSERT(strlen(buf) > 0);
- T_ASSERT(strncmp(line_string, buf, strlen(buf)) == 0);
-
- cleanup:
- return 0;
-}
-
-void test_stream_read_lines(void)
-{
- struct xf_stream s;
- int rc;
- char buf[100];
- bool s_open = false;
-
- for(int bufsz = 38; bufsz <= 100; bufsz += 1) {
- rc = xf_open_file(TESTFILE_SHUFFLED, O_RDONLY, &s);
- T_ASSERT(rc == 0);
- s_open = true;
-
- int max_n = 0;
- rc = xf_stream_read_lines(&s, buf, bufsz, &read_line_cb, &max_n);
- T_ASSERT(rc == 0);
- T_ASSERT(max_n+1 == 108);
-
- xf_stream_close(&s);
- s_open = false;
- }
-
- cleanup:
- if(s_open)
- xf_stream_close(&s);
- return;
-}
-
-void test_stream_read_line_too_long(void)
-{
- struct xf_stream s;
- int rc;
- char buf[38];
- bool s_open = false;
-
- for(int bufsz = 0; bufsz <= 38; bufsz += 1) {
- rc = xf_open_file(TESTFILE_SORTED, O_RDONLY, &s);
- T_ASSERT(rc == 0);
- s_open = true;
-
- int max_n = -1;
- rc = xf_stream_read_lines(&s, buf, bufsz, &read_line_cb, &max_n);
- if(bufsz == 38) {
- T_ASSERT(rc == 0);
- T_ASSERT(max_n+1 == 36);
- } else {
- T_ASSERT(rc == XF_E_LINE_TOO_LONG);
- if(bufsz <= 1)
- T_ASSERT(max_n == -1);
- else
- T_ASSERT(max_n+1 == bufsz-2);
- }
-
- xf_stream_close(&s);
- s_open = false;
- }
-
- cleanup:
- if(s_open)
- xf_stream_close(&s);
- return;
-}