Browse Source

Make parse_texts visible to test.

master
linse 1 year ago
parent
commit
03e5460b38
  1. 4
      src/vcard.ml
  2. 1
      src/vcard.mli
  3. 20
      test/test.ml

4
src/vcard.ml

@ -2060,6 +2060,10 @@ let parse (lines : string) : (card list, string) result =
try parse_string (many vcard) @@ unfold lines
with Parse_error e -> Error ("parse error: " ^ e)
let parse_texts (lines : string) : (string list, string) result =
try parse_string texts @@ unfold lines
with Parse_error e -> Error ("parse error: " ^ e)
let recur_dates dtstart (rrule : recurrence) =
Recurrence.new_gen dtstart rrule

1
src/vcard.mli

@ -246,6 +246,7 @@ type cards = card list
val parse_datetime: string -> (timestamp, string) result
val parse : string -> (cards, string) result
val parse_texts : string -> (string list, string) result
val pp : cards Fmt.t
(* TODO this actually belongs to CalDAV! this is Webdav_xml module! *)

20
test/test.ml

@ -63,6 +63,25 @@ let escaping () =
let line = to_vcard {_|FN:Text with\nOtherline|_} in
Alcotest.check result "test short line" expected (parse line)
(* 4. Property Value Data Types *)
let text () =
let expected = Ok ["this is a single value" ; "this is another"] in
let texts = {_|this is a single value,this is another|_} in
Alcotest.(check (result (list string) string)) __LOC__ expected (parse_texts texts);
let expected = Ok ["this is a single value, with a comma encoded"] in
let texts = {_|this is a single value\, with a comma encoded|_} in
Alcotest.(check (result (list string) string)) __LOC__ expected (parse_texts texts);
let texts = {_|Mythical Manager\nHyjinx Software Division\n
BabsCo\, Inc.\n
|_} in
let expected =
Ok ["Mythical Manager
Hyjinx Software Division
BabsCo, Inc.
"]
in
Alcotest.(check (result (list string) string)) __LOC__ expected (parse_texts texts)
(*
let cards_object () =
let input =
@ -1751,6 +1770,7 @@ let object_tests = [
"test multiline", `Quick, multiline ;
"test escaping", `Quick, escaping ;
"test text", `Quick, text ;
(*
"cards object parsing", `Quick, cards_object ;
"cards object parsing with tzid", `Quick, cards_object_with_tzid ;

Loading…
Cancel
Save