aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/Makefile.am10
-rw-r--r--src/test/test_hagelbarger.c29
2 files changed, 38 insertions, 1 deletions
diff --git a/src/test/Makefile.am b/src/test/Makefile.am
index 852c235..dbe6c73 100644
--- a/src/test/Makefile.am
+++ b/src/test/Makefile.am
@@ -7,7 +7,8 @@ noinst_PROGRAMS = \
test_emphasis \
test_dms \
test_sms \
- test_performance
+ test_performance \
+ test_hagelbarger
test_filter_SOURCES = test_filter.c dummy.c
@@ -77,3 +78,10 @@ test_performance_LDADD = \
$(SOAPY_LIBS) \
-lm
+test_hagelbarger_SOURCES = \
+ $(top_builddir)/src/nmt/hagelbarger.c \
+ test_hagelbarger.c
+
+test_hagelbarger_LDADD = \
+ $(COMMON_LA)
+
diff --git a/src/test/test_hagelbarger.c b/src/test/test_hagelbarger.c
new file mode 100644
index 0000000..d4117e3
--- /dev/null
+++ b/src/test/test_hagelbarger.c
@@ -0,0 +1,29 @@
+#include "stdio.h"
+#include "stdint.h"
+#include "string.h"
+#include "../nmt/hagelbarger.h"
+
+int main(void)
+{
+ uint8_t message[9] = "JollyRog", code[20];
+
+ printf("Message: %s\n", message);
+
+ /* clean tail at code bit 72 and above */
+ memset(code, 0, sizeof(code));
+
+ /* encode message */
+ hagelbarger_encode(message, code, 72);
+
+ /* corrupt data */
+ code[0] ^= 0xfc;
+ code[3] ^= 0xfc;
+ code[7] ^= 0xfc;
+
+ /* decode */
+ hagelbarger_decode(code, message, 64);
+ printf("Decoded: %s (must be the same as above)\n", message);
+
+ return 0;
+}
+