Permalink
Browse files

remove old ctest sources; use new submodule ctest instead

  • Loading branch information...
1 parent 8bd0ed7 commit 6984debe8da00d9a5ae92a9c1c24256554e15e66 @cmosher01 committed Apr 30, 2012
Showing with 14 additions and 258 deletions.
  1. +4 −4 src/Makefile.am
  2. +1 −1 src/a2catalog.c
  3. +1 −1 src/a2nibblize.c
  4. +0 −120 src/ctest.c
  5. +0 −124 src/ctest.h
  6. +1 −1 src/nibblize_4_4.c
  7. +1 −1 src/nibblize_4_4.h
  8. +1 −1 src/nibblize_5_3.c
  9. +1 −1 src/nibblize_5_3.h
  10. +1 −1 src/nibblize_5_3_alt.c
  11. +1 −1 src/nibblize_5_3_alt.h
  12. +1 −1 src/nibblize_6_2.c
  13. +1 −1 src/nibblize_6_2.h
View
@@ -12,8 +12,8 @@ a2catalog.c\
a2catalog_opt.c\
a2catalog_opt.h\
a2const.h\
-ctest.c\
-ctest.h
+ctest/ctest.c\
+ctest/ctest.h
a2nibblize_SOURCES=\
a2nibblize.c\
@@ -30,8 +30,8 @@ nibblize_5_3_common.h\
nibblize_6_2.c\
nibblize_6_2.h\
a2const.h\
-ctest.c\
-ctest.h
+ctest/ctest.c\
+ctest/ctest.h
View
@@ -10,7 +10,7 @@
#include <minmax.h>
#include <binary-io.h>
-#include "ctest.h"
+#include "ctest/ctest.h"
#include "a2const.h"
#include "a2catalog_opt.h"
#include "nibblize_4_4.h"
View
@@ -7,7 +7,7 @@
#include <stdio.h>
#include <binary-io.h>
-#include "ctest.h"
+#include "ctest/ctest.h"
#include "a2const.h"
#include "a2nibblize_opt.h"
#include "nibblize_4_4.h"
View
@@ -1,120 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "ctest.h"
-
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-
-
-
-/*
- CTEST suite context. It just contains
- counts of tests passed and failed.
-*/
-struct ctest_ctx
- {
- long magic;
- long c_pass;
- long c_fail;
- };
-
-
-/*
-Fill unused memory with 0x95.
-This is the only value that meets these conditions:
-1. has 8 bits
-2. has 4 bits set and 4 bits clear (10010101)
-3. when unsigned, is prime (149)
-4. when signed, is negative (high-order bit set)
-5. when signed, has a nagative prime (-107)
-6. has an odd high-order nibble (9)
-*/
-#define BAD_MEM 0x95
-
-/* Magic bytes: "CTst" */
-#define MAGIC 0x74735443
-
-static void ctest_ctx_check(const ctest_ctx *const ctx)
-{
- assert(ctx);
- assert(ctx->magic==MAGIC);
- assert(ctx->c_pass >= 0);
- assert(ctx->c_fail >= 0);
-}
-
-/*
- Allocation and deallocation of the suite context
-*/
-ctest_ctx *ctest_ctx_alloc(void)
-{
- ctest_ctx *const ctx = (ctest_ctx*)malloc(sizeof(*ctx));
- memset(ctx,BAD_MEM,sizeof(ctest_ctx));
-
- ctx->magic = MAGIC;
-
- ctx->c_pass = 0;
- ctx->c_fail = 0;
-
- ctest_ctx_check(ctx);
-
- return ctx;
-}
-
-void ctest_ctx_free(ctest_ctx *const ctx)
-{
- ctest_ctx_check(ctx);
- if (!ctest_count_test(ctx))
- {
- fprintf(stderr,"Warning: no CTEST unit tests were run.\n");
- }
- memset(ctx,BAD_MEM,sizeof(ctest_ctx));
- free(ctx);
-}
-
-
-/*
- The main test function (best called by the CTEST macro).
- If is_true is false, print an error message containing
- file_name, line_number. and name.
- Update counts in the given suite context ctx.
-*/
-void ctest(ctest_ctx *const ctx, const char *const name, const int is_true, const char *const file_name, const unsigned long line_number)
-{
- ctest_ctx_check(ctx);
- if (is_true)
- {
- ++ctx->c_pass;
- }
- else
- {
- ++ctx->c_fail;
- fprintf(stderr,"%s:%lu: test failed: %s\n",file_name,line_number,name);
- }
-}
-
-
-
-/*
- Simple accessors for the counts
-*/
-long ctest_count_pass(const ctest_ctx *const ctx)
-{
- ctest_ctx_check(ctx);
- return ctx->c_pass;
-}
-
-long ctest_count_fail(const ctest_ctx *const ctx)
-{
- ctest_ctx_check(ctx);
- return ctx->c_fail;
-}
-
-long ctest_count_test(const ctest_ctx *const ctx)
-{
- ctest_ctx_check(ctx);
- return ctx->c_pass+ctx->c_fail;
-}
View
@@ -1,124 +0,0 @@
-#ifndef UUID_b743105c6bd5471c871fa85d8ec31a1c
-#define UUID_b743105c6bd5471c871fa85d8ec31a1c
-
-/*
- CTEST -- A simple unit test framework for C
- Copyright (C) 2011, by Christopher A. Mosher
-
- 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 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-
-
-/*
-
-CTEST is a very simple unit test framework for C.
-Its main functions are to check for pass/fail of tests,
-print error messages for failures, and keep count.
-
-To use the CTEST framework, perform to following
-actions:
- 1. Call ctest_ctx_alloc to allocate a suite context.
- 2. Call the CTEST macro for each unit test to perform.
- 3. Check the count of failed tests in the suite by
- calling ctest_count_failures.
- 4. Call ctest_ctx_free to free the suite context.
-
-Here is a simple example:
-
-#include "ctest.h"
-int main(int argc, char **argv)
-{
- int f;
-
- ctest_ctx *ctx = ctest_ctx_alloc();
-
- CTEST(ctx,9/3==3);
- CTEST(ctx,10/3==3);
- f = ctest_count_fail(ctx);
-
- ctest_ctx_free(ctx);
-
- if (f)
- {
- return 1;
- }
-
- return 0;
-}
-
-*/
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-
-
-
-/*
- Opaque structure containing the CTEST context for
- one suite of unit tests.
-*/
-struct ctest_ctx;
-typedef struct ctest_ctx ctest_ctx;
-
-
-
-/*
- Functions to allocate and deallocate a CTEST context.
-*/
-extern ctest_ctx *ctest_ctx_alloc(void);
-extern void ctest_ctx_free(ctest_ctx *ctx);
-
-
-
-/*
- Performs one unit test. Call the CTEST macro for each unit
- test to perform. Use the CTEST macro, not the ctest
- function directly, because the CTEST macro gets the current
- file name and line number of the test (which it uses in the
- error message in case the test fails).
- ctx is the CTEST context, which must have been allocated by
- a call to ctest_ctx_alloc.
- assertion is the boolean expression to test. If the expression
- evaluates to non-zero (true), then the test is considered
- correct; if the expression evaluates to zero (false), then
- the test is considered failed.
-*/
-#define CTEST(ctx,assertion) ctest(ctx,#assertion,assertion,__FILE__,__LINE__)
-
-extern void ctest(ctest_ctx *ctx, const char *name, int is_true, const char *file_name, const unsigned long line_number);
-
-
-
-/*
- Accessor functions to get the (current) count of tests
- that passed or failed.
-*/
-extern long ctest_count_pass(const ctest_ctx *ctx);
-extern long ctest_count_fail(const ctest_ctx *ctx);
-extern long ctest_count_test(const ctest_ctx *ctx);
-
-
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
View
@@ -6,7 +6,7 @@
#include <stdint.h>
-#include "ctest.h"
+#include "ctest/ctest.h"
View
@@ -2,7 +2,7 @@
#define UUID_6881609590944a84af78213e0cc16550
#include <stdint.h>
-#include "ctest.h"
+#include "ctest/ctest.h"
extern uint16_t nibblize_4_4_encode(uint8_t n);
extern uint8_t nibblize_4_4_decode(uint16_t n);
View
@@ -8,7 +8,7 @@
#include <string.h>
#include <stdlib.h>
-#include "ctest.h"
+#include "ctest/ctest.h"
#include "nibblize_5_3_common.h"
View
@@ -2,7 +2,7 @@
#define UUID_d901a32e0e3e4805a76264474fb28d05
#include <stdint.h>
-#include "ctest.h"
+#include "ctest/ctest.h"
void nibblize_5_3_encode(const uint8_t **original, uint8_t **encoded);
void nibblize_5_3_decode(const uint8_t **original, uint8_t **decoded);
@@ -8,7 +8,7 @@
#include <string.h>
#include <stdlib.h>
-#include "ctest.h"
+#include "ctest/ctest.h"
#include "nibblize_5_3_common.h"
static void nibblize(const uint8_t **pdata, uint8_t **encoded)
@@ -2,7 +2,7 @@
#define UUID_eeba25b1054b4b6aa5bbb7426a9ec7e1
#include <stdint.h>
-#include "ctest.h"
+#include "ctest/ctest.h"
void nibblize_5_3_alt_encode(const uint8_t **original, uint8_t **encoded);
void nibblize_5_3_alt_decode(const uint8_t **original, uint8_t **decoded);
View
@@ -8,7 +8,7 @@
#include <string.h>
#include <stdlib.h>
-#include "ctest.h"
+#include "ctest/ctest.h"
View
@@ -2,7 +2,7 @@
#define UUID_30af0ca9a8a74a59a85b2e33670ed1ce
#include <stdint.h>
-#include "ctest.h"
+#include "ctest/ctest.h"
void nibblize_6_2_encode(const uint8_t **original, uint8_t **encoded);
void nibblize_6_2_decode(const uint8_t **original, uint8_t **decoded);

0 comments on commit 6984deb

Please sign in to comment.