diff options
author | Pierre Weis <Pierre.Weis@inria.fr> | 2009-03-30 09:55:41 +0000 |
---|---|---|
committer | Pierre Weis <Pierre.Weis@inria.fr> | 2009-03-30 09:55:41 +0000 |
commit | aa3a23cd3d3fe6db6e94f0400d7241fb01d1e383 (patch) | |
tree | 719174884d020d9831e86daf68d01b06ef8bf608 | |
parent | 0515798a72b9eb5ca4f6b845ecd35e11c10b3596 (diff) |
Adding tests for %S scanning.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@9207 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | test/Moretest/tscanf.ml | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/test/Moretest/tscanf.ml b/test/Moretest/tscanf.ml index 24bf40fac..dd7d2a60b 100644 --- a/test/Moretest/tscanf.ml +++ b/test/Moretest/tscanf.ml @@ -169,7 +169,7 @@ test (test8 ()) (* %S and %s styles. *) let unit fmt s = - let ib = Scanning.from_string (Printf.sprintf "%S" s) in + let ib = Scanning.from_string (Printf.sprintf "\"%S\"" s) in Scanf.bscanf ib fmt id ;; @@ -197,11 +197,24 @@ test (test9 ()) ;; let test10 () = + let unit s = + let ib = Scanning.from_string s in + Scanf.bscanf ib "%S" id in + let res = sscanf "Une chaîne: \"celle-ci\" et \"celle-là\"!" "%s %s %S %s %S %s" (fun s1 s2 s3 s4 s5 s6 -> s1 ^ s2 ^ s3 ^ s4 ^ s5 ^ s6) in - res = "Unechaîne:celle-cietcelle-là!" + res = "Unechaîne:celle-cietcelle-là!" && + (* Testing the result of reading a %S string. *) + unit "\"a\\\n b\"" = "ab" && + unit "\"\\\n ab\"" = "ab" && + unit "\"\n\\\n ab\"" = "\nab" && + unit "\"\n\\\n a\nb\"" = "\na\nb" && + unit "\"\n\\\n \\\n a\nb\"" = "\na\nb" && + unit "\"\n\\\n a\n\\\nb\\\n\"" = "\na\nb" && + unit "\"a\\\n \"" = "a" && + true ;; test (test10 ()) |