summaryrefslogtreecommitdiff
path: root/source4/build/pidl/tests/ndr_string.pl
diff options
context:
space:
mode:
Diffstat (limited to 'source4/build/pidl/tests/ndr_string.pl')
-rw-r--r--source4/build/pidl/tests/ndr_string.pl59
1 files changed, 59 insertions, 0 deletions
diff --git a/source4/build/pidl/tests/ndr_string.pl b/source4/build/pidl/tests/ndr_string.pl
new file mode 100644
index 0000000000..9ea4ca42b6
--- /dev/null
+++ b/source4/build/pidl/tests/ndr_string.pl
@@ -0,0 +1,59 @@
+#!/usr/bin/perl
+# String tests for pidl
+# (C) 2005 Jelmer Vernooij <jelmer@samba.org>
+# Published under the GNU General Public License
+use strict;
+
+use FindBin qw($RealBin);
+use lib "$RealBin/..";
+use test;
+
+my %settings = Test::GetSettings(@ARGV);
+
+$settings{'IDL-Arguments'} = ['--quiet', '--parse', '--parser=ndr_test.c', '--header=ndr_test.h'];
+$settings{'IncludeFiles'} = ['ndr_test.h'];
+$settings{'ExtraFiles'} = ['ndr_test.c'];
+
+Test::test_idl("string-pull-empty", \%settings,
+' [public] void TestString([in,flag(STR_ASCII|LIBNDR_FLAG_STR_SIZE4)] string data);',
+'
+ uint8_t data[] = { 0x00, 0x00, 0x00, 0x00 };
+ DATA_BLOB b = { data, 4 };
+ struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
+ struct TestString r;
+ r.in.data = NULL;
+
+ if (NT_STATUS_IS_ERR(ndr_pull_TestString(ndr, NDR_IN, &r)))
+ return 1;
+
+ if (r.in.data == NULL)
+ return 2;
+
+ if (r.in.data[0] != 0)
+ return 3;
+');
+
+Test::test_idl("string-ascii-pull", \%settings,
+'
+ [public] void TestString([in,flag(STR_ASCII|LIBNDR_FLAG_STR_SIZE4)] string data);
+',
+'
+ uint8_t data[] = { 0x03, 0x00, 0x00, 0x00,
+ \'f\', \'o\', \'o\', 0 };
+ DATA_BLOB b = { data, 8 };
+ struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
+ struct TestString r;
+ r.in.data = NULL;
+
+ if (NT_STATUS_IS_ERR(ndr_pull_TestString(ndr, NDR_IN, &r)))
+ return 1;
+
+ if (r.in.data == NULL)
+ return 2;
+
+ if (strncmp(r.in.data, "foo", 3) != 0)
+ return 3;
+
+ if (r.in.data[4] != 0)
+ return 4;
+');