readme
[Seppo.git] / test / t_st.ml
blob9428e494573b52e080dc12ee8796b8f5fc65b3d5
1 (*
2 * _ _ ____ _
3 * _| || |_/ ___| ___ _ __ _ __ ___ | |
4 * |_ .. _\___ \ / _ \ '_ \| '_ \ / _ \| |
5 * |_ _|___) | __/ |_) | |_) | (_) |_|
6 * |_||_| |____/ \___| .__/| .__/ \___/(_)
7 * |_| |_|
9 * Personal Social Web.
11 * Copyright (C) The #Seppo contributors. All rights reserved.
13 * This program is free software: you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation, either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 open Seppo_lib
28 let test_dirname () =
29 "./foo/../bar/baz" |> Filename.dirname |> Assrt.equals_string __LOC__ "./foo/../bar"
31 let test_updir () =
32 "" |> St.updir |> Assrt.equals_string __LOC__ "";
33 "foo" |> St.updir |> Assrt.equals_string __LOC__ "";
34 "foo/" |> St.updir |> Assrt.equals_string __LOC__ "../";
35 "/foo/" |> St.updir |> Assrt.equals_string __LOC__ "../";
36 "foo/bar" |> St.updir |> Assrt.equals_string __LOC__ "../";
37 "/foo" |> St.updir |> Assrt.equals_string __LOC__ "";
38 "/foo/bar" |> St.updir |> Assrt.equals_string __LOC__ "../";
39 "/foo/bar/" |> St.updir |> Assrt.equals_string __LOC__ "../../";
40 "/.well-known/webfinger/.htaccess" |> St.updir |> Assrt.equals_string __LOC__ "../../";
41 ".well-known/webfinger/.htaccess" |> St.updir |> Assrt.equals_string __LOC__ "../../"
43 let test_before () =
44 "uhu/index.xml"
45 |> St.before ~suffix:"index.xml"
46 |> Option.get
47 |> Assrt.equals_string __LOC__ "uhu/"
49 let test_window () =
50 Logr.info (fun m -> m "%s" "test_window");
51 let tos l = l |> List.map Int.to_string |> String.concat "; " in
52 let l0 = List.init 37 (fun i -> i) in
53 l0 |> tos |> Assrt.equals_string __LOC__ "0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15; 16; 17; 18; 19; 20; 21; 22; 23; 24; 25; 26; 27; 28; 29; 30; 31; 32; 33; 34; 35; 36";
55 |> St.window ~page:2 ~size:4
56 |> tos |> Assrt.equals_string __LOC__ "8; 9; 10; 11"
58 let test_lambdasoup () =
59 let open Soup in
60 let soup = parse "<p class='Hello'>World!</p>" in
61 wrap (soup $ ".Hello" |> R.child) (create_element "strong");
62 soup |> to_string
63 |> Assrt.equals_string __LOC__ "<p class=\"Hello\"><strong>World!</strong></p>"
65 let () =
66 Logr.info (fun m -> m "st_test");
67 Unix.chdir "../../../test/";
68 test_dirname ();
69 test_updir ();
70 test_before ();
71 test_window ();
72 test_lambdasoup ();