summaryrefslogtreecommitdiff
path: root/test_line.c
diff options
context:
space:
mode:
authorFreeArtMan <dos21h@gmail.com>2019-05-12 15:05:57 +0100
committerFreeArtMan <dos21h@gmail.com>2019-05-12 15:05:57 +0100
commit082dee0658b67744ab3428eea964f375f7aab9dc (patch)
tree6dd58d5044513ec7bef3b445fefa7003e33ebeed /test_line.c
parent654bb8b09dd90c12c3a51ffdce800b2255b753b5 (diff)
downloadlibbuf-082dee0658b67744ab3428eea964f375f7aab9dc.tar.gz
libbuf-082dee0658b67744ab3428eea964f375f7aab9dc.zip
Added more functionality to Buf, substring, search for characer, and shifting string.
Diffstat (limited to 'test_line.c')
-rw-r--r--test_line.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/test_line.c b/test_line.c
new file mode 100644
index 0000000..3c3ccab
--- /dev/null
+++ b/test_line.c
@@ -0,0 +1,65 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "__cpp.h"
+#include "buf.h"
+#include "buf_misc.h"
+#include "debug.h"
+
+void blow_if_error(int err)
+{
+ if (err < 0)
+ {
+ printf("Should be no error but there is\n");
+ exit(1);
+ }
+}
+
+//#define B(X) PNL();blow_if_error(X);
+#define B(X) blow_if_error(X);
+
+void error_is_good(int err)
+{
+ if (err >= 0)
+ {
+ printf("Should be error but there is no\n");
+ exit(1);
+ }
+}
+#define E(X) error_is_good(X);
+
+int main()
+{
+ Buf *b1=NULL, *b2=NULL, *b3=NULL;
+ BufLine *bline=NULL;
+
+ printf("Start test\n");
+ b1 = new Buf(8);
+ b2 = new Buf(8);
+ b3 = new Buf(1);
+ bline = new BufLine(32);
+
+ char n1[] = "Line";
+ char n2[] = "Home";
+ char n3[] = "\n";
+
+ b1->set(n1);
+ b2->set(n2);
+ b3->set(n3);
+ b1->print(); printf("\n");
+ b2->print(); printf("\n");
+ b1->print(); printf("\n");
+ bline->print(); printf("\n");
+
+ printf("Add data\n");
+
+ bline->add(b1); bline->print(); printf("\n");
+ bline->add(b3);
+ bline->add(b2); bline->print(); printf("\n");
+
+ printf("Get line\n");
+
+ printf("End test\n");
+
+ return 0;
+} \ No newline at end of file