search for: assert_equal_string

Displaying 20 results from an estimated 51 matches for "assert_equal_string".

2015 Jan 23
0
[PATCH 2/2] mllib: add simple tests for the JSON module
...* + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *) + +(* This file tests the JSON module. *) + +open OUnit + +(* Utils. *) +let assert_equal_string = assert_equal ~printer:(fun x -> x) + +(* "basic" suite. *) +let test_empty () = + let doc = [] in + assert_equal_string "{}" (JSON.string_of_doc doc); + assert_equal_string "{ +}" (JSON.string_of_doc ~fmt:JSON.Indented doc) + +let test_string () = + let doc =...
2015 Jan 23
2
[PATCH 1/2] mllib: tests: add tests for string_lines_split
...sts.ml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/mllib/common_utils_tests.ml b/mllib/common_utils_tests.ml index 09d5c51..283e9a1 100644 --- a/mllib/common_utils_tests.ml +++ b/mllib/common_utils_tests.ml @@ -27,6 +27,7 @@ let prog = "common_utils_tests" let assert_equal_string = assert_equal ~printer:(fun x -> x) let assert_equal_int = assert_equal ~printer:(fun x -> string_of_int x) let assert_equal_int64 = assert_equal ~printer:(fun x -> Int64.to_string x) +let assert_equal_stringlist = assert_equal ~printer:(fun x -> "(" ^ (String.escaped (Stri...
2015 Jan 22
3
[PATCH 1/2] configure: look for the oUnit OCaml module
It will be used for the OCaml unit tests. --- configure.ac | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configure.ac b/configure.ac index e0fb481..e360bbb 100644 --- a/configure.ac +++ b/configure.ac @@ -1120,6 +1120,7 @@ AS_IF([test "x$OCAMLC" != "xno"],[ ]) OCAML_PKG_gettext=no +OCAML_PKG_oUnit=no AS_IF([test "x$OCAMLC" != "xno"],[ #
2019 Feb 25
0
[PATCH 2/3] v2v: add Var_expander
...the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *) + +open OUnit + +let assert_equal_string = assert_equal ~printer:(fun x -> x) +let assert_equal_stringlist = assert_equal ~printer:(fun x -> "(" ^ (String.escaped (String.concat "," x)) ^ ")") + +let replace_none_fn _ = None +let replace_empty_fn _ = Some "" + +let test_no_replacement () = +...
2015 Jan 22
0
[PATCH 2/2] mllib: convert common_utils_tests to oUnit
...l b/mllib/common_utils_tests.ml index e12297a..09d5c51 100644 --- a/mllib/common_utils_tests.ml +++ b/mllib/common_utils_tests.ml @@ -18,84 +18,117 @@ (* This file tests the Common_utils module. *) +open OUnit open Common_utils let prog = "common_utils_tests" +(* Utils. *) +let assert_equal_string = assert_equal ~printer:(fun x -> x) +let assert_equal_int = assert_equal ~printer:(fun x -> string_of_int x) +let assert_equal_int64 = assert_equal ~printer:(fun x -> Int64.to_string x) + (* Test Common_utils.int_of_le32 and Common_utils.le32_of_int. *) -let () = - assert (int_of_le32 &...
2015 May 11
3
[PATCH 1/2] mllib: Require OUnit2 for tests.
...| O | For building the virt-v2v test harness. | diff --git a/mllib/JSON_tests.ml b/mllib/JSON_tests.ml index fa37171..281d38e 100644 --- a/mllib/JSON_tests.ml +++ b/mllib/JSON_tests.ml @@ -18,19 +18,19 @@ (* This file tests the JSON module. *) -open OUnit +open OUnit2 (* Utils. *) let assert_equal_string = assert_equal ~printer:(fun x -> x) (* "basic" suite. *) -let test_empty () = +let test_empty ctx = let doc = [] in assert_equal_string "{}" (JSON.string_of_doc doc); assert_equal_string "{ }" (JSON.string_of_doc ~fmt:JSON.Indented doc) -let test_str...
2017 Jul 21
3
[PATCH] common/mlstdutils: Add chomp function to remove \n from end of strings.
...s.ml +++ b/common/mlstdutils/std_utils_tests.ml @@ -110,6 +110,15 @@ let test_string_span ctx = assert_equal_int 3 (String.cspan "def" "ab"); assert_equal_int 0 (String.cspan "" "ab") +(* Test Std_utils.String.chomp. *) +let test_string_chomp ctx = + assert_equal_string "a" (String.chomp "a"); + assert_equal_string "a" (String.chomp "a\n"); + assert_equal_string "a\nb" (String.chomp "a\nb"); + assert_equal_string "" (String.chomp ""); + assert_equal_string "" (String.chom...
2019 Mar 29
5
[PATCH v2 0/3] v2v: add -o json output mode
This series adds a new output mode for virt-v2v, called -o json. It produces local files, just like -o local, although the metadata produced is a JSON file with data that v2v collected in the conversion process. This can be useful for converting to unsupported destinations, still based on QEMU/KVM. In addition to a simple different metadata, it offers a way to relocate the disks, with
2017 Jun 20
2
[PATCH v2 1/2] mllib: add new Common_utils.run_commands
...ng a shell, and return its exit code. [echo_cmd] specifies whether output the full command on verbose diff --git a/mllib/common_utils_tests.ml b/mllib/common_utils_tests.ml index aacc01e..4c9f53f 100644 --- a/mllib/common_utils_tests.ml +++ b/mllib/common_utils_tests.ml @@ -26,6 +26,7 @@ let assert_equal_string = assert_equal ~printer:(fun x -> x) let assert_equal_int = assert_equal ~printer:(fun x -> string_of_int x) let assert_equal_int64 = assert_equal ~printer:(fun x -> Int64.to_string x) let assert_equal_stringlist = assert_equal ~printer:(fun x -> "(" ^ (String.escaped (Stri...
2018 Aug 20
6
[PATCH 0/4] mltools: JSON unification
An evolution of: https://www.redhat.com/archives/libguestfs/2018-August/msg00155.html
2017 Apr 07
1
[PATCH 1/2] mllib: add new Common_utils.run_commands
...-> string list -> int (** Run an external command without using a shell, and return its exit code. diff --git a/mllib/common_utils_tests.ml b/mllib/common_utils_tests.ml index aacc01e..42af7be 100644 --- a/mllib/common_utils_tests.ml +++ b/mllib/common_utils_tests.ml @@ -26,6 +26,7 @@ let assert_equal_string = assert_equal ~printer:(fun x -> x) let assert_equal_int = assert_equal ~printer:(fun x -> string_of_int x) let assert_equal_int64 = assert_equal ~printer:(fun x -> Int64.to_string x) let assert_equal_stringlist = assert_equal ~printer:(fun x -> "(" ^ (String.escaped (Stri...
2019 Jan 11
3
[PATCH 1/3] mlstdutils: add a very simple test for Std_utils.which
...index 81f512cbf..f7b0247a4 100644 --- a/common/mlstdutils/std_utils_tests.ml +++ b/common/mlstdutils/std_utils_tests.ml @@ -29,6 +29,11 @@ let assert_equal_int = assert_equal ~printer:(fun x -> string_of_int x) let assert_equal_int64 = assert_equal ~printer:(fun x -> Int64.to_string x) let assert_equal_stringlist = assert_equal ~printer:(fun x -> "(" ^ (String.escaped (String.concat "," x)) ^ ")") let assert_equal_stringpair = assert_equal ~printer:(fun (x, y) -> sprintf "%S, %S" x y) +let assert_nonempty_string str = + if str = "" then + asse...
2019 Feb 25
7
[PATCH 0/3] RFC: v2v: add -o json output mode
This series adds a new output mode for virt-v2v, called -o json. It produces local files, just like -o local, although the metadata produced is a JSON file with data that v2v collected in the conversion process. This can be useful for converting to unsupported destinations, still based on QEMU/KVM. In addition to a simple different metadata, it offers a way to relocate the disks, with
2018 Aug 20
0
[PATCH 4/4] mltools: JSON: unify JSON_parser type with JSON.json_t.
...ssert_is_object value = assert_bool (type_mismatch_string "object" value) - (match value with | JSON_parser_object _ -> true | _ -> false) + (match value with | JSON.Dict _ -> true | _ -> false) let assert_is_string exp = function - | JSON_parser_string s -> assert_equal_string exp s + | JSON.String s -> assert_equal_string exp s | _ as v -> assert_failure (type_mismatch_string "string" v) let assert_is_number exp = function - | JSON_parser_number n -> assert_equal_int64 exp n - | JSON_parser_double d -> assert_equal_int64 exp (Int64.of_float...
2018 Aug 22
3
[PATCH v2 0/2] mltools: JSON: unify JSON & JSON parser.
v2: - Added back the null value. - Reran the tests. Rich.
2019 Jan 16
1
Re: [PATCH 3/5] mltools: add simple tests for external_command
...++ > 1 file changed, 22 insertions(+) > > diff --git a/common/mltools/tools_utils_tests.ml b/common/mltools/tools_utils_tests.ml > index 1489fe699..f3c39514d 100644 > --- a/common/mltools/tools_utils_tests.ml > +++ b/common/mltools/tools_utils_tests.ml > @@ -28,6 +28,7 @@ let assert_equal_string = assert_equal ~printer:(fun x -> x) > let assert_equal_int = assert_equal ~printer:(fun x -> string_of_int x) > let assert_equal_int64 = assert_equal ~printer:(fun x -> Int64.to_string x) > let assert_equal_intlist = assert_equal ~printer:(fun x -> "(" ^ (String.c...
2018 Aug 17
0
[PATCH v3 1/4] mltools: Rename Yajl module as JSON_parser and move to common/mltools.
.../yajl_tests.ml +++ b/common/mltools/JSON_parser_tests.ml @@ -16,10 +16,10 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) -(* This file tests the Yajl module. *) +(* This file tests the JSON_parser module. *) open OUnit2 -open Yajl +open JSON_parser (* Utils. *) let assert_equal_string = assert_equal ~printer:(fun x -> x) @@ -27,16 +27,16 @@ let assert_equal_int = assert_equal ~printer:(fun x -> string_of_int x) let assert_equal_int64 = assert_equal ~printer:(fun x -> Int64.to_string x) let assert_equal_bool = assert_equal ~printer:(fun x -> string_of_bool x) -let...
2017 Mar 07
0
[PATCH v4 5/9] builder: add Index_parser.write_entry function
...quot;";; +rmdir_on_exit tmpdir + +let dummy_sigchecker = Sigchecker.create ~gpg:"gpg" + ~check_signature:false + ~gpgkey:Utils.No_Key + ~tmpdir + +(* Utils. *) +let assert_equal_string = assert_equal ~printer:(fun x -> sprintf "\"%s\"" x) + +let test_open_out () = + open_out (tmpdir // "out") + +let test_read_out chan = + close_out chan; + read_whole_file (tmpdir // "out") + +let test_write_complete ctx = + let entry = + ("te...
2017 Sep 18
0
[PATCH v9 4/7] builder: add Index.write_entry function
...in + List.map ( + fun (id, e) -> (id, { e with Index.file_uri = Filename.basename e.Index.file_uri }) + ) entries + +let format_entries entries = + let format_entry entry = + write_entries "out" [entry]; + read_file "out" in + List.map format_entry entries + +let assert_equal_string = assert_equal ~printer:(fun x -> sprintf "\"%s\"" x) +let assert_equal_list formatter = + let printer = ( + fun x -> "(" ^ (String.escaped (String.concat "," (formatter x))) ^ ")" + ) in + assert_equal ~printer + +let test_write_complet...
2017 Oct 27
0
[PATCH v11 6/8] builder: add Index.write_entry function
...in + List.map ( + fun (id, e) -> (id, { e with Index.file_uri = Filename.basename e.Index.file_uri }) + ) entries + +let format_entries entries = + let format_entry entry = + write_entries "out" [entry]; + read_file "out" in + List.map format_entry entries + +let assert_equal_string = assert_equal ~printer:(fun x -> sprintf "\"%s\"" x) +let assert_equal_list formatter = + let printer = ( + fun x -> "(" ^ (String.escaped (String.concat "," (formatter x))) ^ ")" + ) in + assert_equal ~printer + +let test_write_complet...