aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/core/test_sscanf_hex.in24
-rw-r--r--tests/core/test_sscanf_hex.out3
2 files changed, 24 insertions, 3 deletions
diff --git a/tests/core/test_sscanf_hex.in b/tests/core/test_sscanf_hex.in
index d8175e82..a05eb890 100644
--- a/tests/core/test_sscanf_hex.in
+++ b/tests/core/test_sscanf_hex.in
@@ -1,7 +1,27 @@
-#include "stdio.h"
+#include <stdio.h>
+#include <string>
+#include <cstdlib>
-int main() {
+int main()
+{
unsigned int a, b;
sscanf("0x12AB 12AB", "%x %x", &a, &b);
printf("%d %d\n", a, b);
+
+ std::string hexstr("0102037F00FF");
+ const char * cstr = hexstr.c_str();
+ int len = hexstr.length() / 2;
+ char * tmp_data = new char[len];
+ for(int i = 0; i < len; i++)
+ {
+ sscanf(cstr, "%2hhx", &tmp_data[i]);
+ cstr += 2 * sizeof(char);
+ }
+
+ for (int j = 0; j < len; j++)
+ printf("%i, ", tmp_data[j]);
+ printf("\n");
+ delete[] tmp_data;
}
+
+
diff --git a/tests/core/test_sscanf_hex.out b/tests/core/test_sscanf_hex.out
index ac855044..6e7f66aa 100644
--- a/tests/core/test_sscanf_hex.out
+++ b/tests/core/test_sscanf_hex.out
@@ -1 +1,2 @@
-4779 4779 \ No newline at end of file
+4779 4779
+1, 2, 3, 127, 0, -1,