Refactor: @Test whitespace clean-up and other corelib changes

xowa2
gnosygnu 3 years ago
parent 2a4abd8f75
commit b0082fd231

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="tst"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="lib/commons-compress-1.18.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/xz-1.5.jar"/>
<classpathentry kind="lib" path="lib/Saxon-HE-9.9.1-2.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

@ -1,34 +1,34 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;
public class Array__tst {
@Test public void Resize_add() {
@Test public void Resize_add() {
tst_Resize_add(ary_(), ary_(1), ary_(1)); // 0 + 1 = 1
tst_Resize_add(ary_(0), ary_(), ary_(0)); // 1 + 0 = 1
tst_Resize_add(ary_(0), ary_(1), ary_(0, 1)); // 1 + 1 = 2
} void tst_Resize_add(int[] source, int[] added, int[] expd) {Tfds.Eq_ary(expd, (int[])Array_.Resize_add(source, added));}
@Test public void Resize() {
@Test public void Resize() {
tst_Resize(ary_(0), 0, ary_()); // 1 -> 0
tst_Resize(ary_(0, 1), 1, ary_(0)); // 2 -> 1
} void tst_Resize(int[] source, int length, int[] expd) {Tfds.Eq_ary(expd, (int[])Array_.Resize(source, length));}
@Test public void Insert() {
@Test public void Insert() {
tst_Insert(ary_obj(0, 1, 4, 5), ary_obj(2, 3), 2, ary_obj(0, 1, 2, 3, 4, 5));
} void tst_Insert(Object[] cur, Object[] add, int addPos, Object[] expd) {Tfds.Eq_ary(expd, Array_.Insert(cur, add, addPos));}
@Test public void ReplaceInsert() {
@Test public void ReplaceInsert() {
tst_ReplaceInsert(ary_obj(0, 1, 4, 5) , ary_obj(1, 2, 3), 1, 1, ary_obj(0, 1, 2, 3, 4, 5));
tst_ReplaceInsert(ary_obj(0, 1, 2, 4, 5) , ary_obj(1, 2, 3), 1, 2, ary_obj(0, 1, 2, 3, 4, 5));
tst_ReplaceInsert(ary_obj(0, 1, 2, 3, 4, 5) , ary_obj(1, 2, 3), 1, 3, ary_obj(0, 1, 2, 3, 4, 5));

@ -13,17 +13,17 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;
public class Bool__tst {
private final Bool__fxt fxt = new Bool__fxt();
@Test public void Compare() {
fxt.Test__compare(Bool_.Y, Bool_.Y, CompareAble_.Same);
fxt.Test__compare(Bool_.N, Bool_.N, CompareAble_.Same);
fxt.Test__compare(Bool_.N, Bool_.Y, CompareAble_.Less);
fxt.Test__compare(Bool_.Y, Bool_.N, CompareAble_.More);
}
}
class Bool__fxt {
public void Test__compare(boolean lhs, boolean rhs, int expd) {Tfds.Eq(expd, Bool_.Compare(lhs, rhs));}
}
package gplx;
import org.junit.*;
public class Bool__tst {
private final Bool__fxt fxt = new Bool__fxt();
@Test public void Compare() {
fxt.Test__compare(Bool_.Y, Bool_.Y, CompareAble_.Same);
fxt.Test__compare(Bool_.N, Bool_.N, CompareAble_.Same);
fxt.Test__compare(Bool_.N, Bool_.Y, CompareAble_.Less);
fxt.Test__compare(Bool_.Y, Bool_.N, CompareAble_.More);
}
}
class Bool__fxt {
public void Test__compare(boolean lhs, boolean rhs, int expd) {Tfds.Eq(expd, Bool_.Compare(lhs, rhs));}
}

@ -1,34 +1,34 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*; import gplx.core.tests.*;
public class Bry_bfr_tst {
public class Bry_bfr_tst {
private Bry_bfr bb = Bry_bfr_.New();
@Before public void setup() {bb.Clear();} private ByteAryBfr_fxt fxt = new ByteAryBfr_fxt();
@Test public void AddByte() {
@Test public void AddByte() {
bb = Bry_bfr_.New_w_size(2); // NOTE: make sure auto-expands
tst_AddByte("a", "a", 2);
tst_AddByte("b", "ab", 2);
tst_AddByte("c", "abc", 4);
}
@Test public void AddAry() { // NOTE: make sure auto-expands
@Test public void AddAry() { // NOTE: make sure auto-expands
bb = Bry_bfr_.New_w_size(2);
tst_AddByte("abcd", "abcd", 12);
}
@Test public void Add_byte_repeat() { // NOTE: make sure auto-expands
@Test public void Add_byte_repeat() { // NOTE: make sure auto-expands
bb = Bry_bfr_.New_w_size(2);
tst_Add_byte_repeat(Byte_ascii.Space, 12, String_.Repeat(" ", 12));
} void tst_Add_byte_repeat(byte b, int len, String expd) {Tfds.Eq(expd, bb.Add_byte_repeat(b, len).To_str_and_clear());}
@ -40,14 +40,14 @@ public class Bry_bfr_tst {
Tfds.Eq(expdStr, String_.new_u8(bb.To_bry()));
Tfds.Eq(expdLen, bb.Bfr_max());
}
@Test public void Add_dte() {
@Test public void Add_dte() {
tst_AddDte("20110801 221435.987");
}
void tst_AddDte(String raw) {
bb.Add_dte(DateAdp_.parse_fmt(raw, Bry_.Fmt_csvDte));
Tfds.Eq(raw, String_.new_u8(bb.To_bry()));
}
@Test public void Add_int_variable() {
@Test public void Add_int_variable() {
Add_int_variable(-1);
Add_int_variable(-12);
Add_int_variable(-1234);
@ -56,7 +56,7 @@ public class Bry_bfr_tst {
Add_int_variable(1234);
Add_int_variable(123456789);
}
@Test public void Add_float() {
@Test public void Add_float() {
tst_Add_float(1 / 3);
tst_Add_float(-1 / 3);
}
@ -69,26 +69,26 @@ public class Bry_bfr_tst {
bb.Add_int_variable(val);
Tfds.Eq(val, Int_.Parse(String_.new_u8(bb.To_bry())));
}
@Test public void Add_int_fixed_len3() {tst_Add_int_fixed(123, 3, "123");}
@Test public void Add_int_fixed_pad_1() {tst_Add_int_fixed(2, 1, "2");}
@Test public void Add_int_fixed_pad_2() {tst_Add_int_fixed(2, 2, "02");}
@Test public void Add_int_fixed_pad_16() {tst_Add_int_fixed(2, 16, "0000000000000002");} // test overflows int
@Test public void Add_int_fixed_neg() {tst_Add_int_fixed(-2, 2, "-2");}
@Test public void Add_int_fixed_neg_pad1() {tst_Add_int_fixed(-2, 1, "-");}
@Test public void Add_int_fixed_chop_1() {tst_Add_int_fixed(123, 1, "3");}
@Test public void Add_int_fixed_chop_neg() {tst_Add_int_fixed(-21, 2, "-1");}
@Test public void Add_int_fixed_len3() {tst_Add_int_fixed(123, 3, "123");}
@Test public void Add_int_fixed_pad_1() {tst_Add_int_fixed(2, 1, "2");}
@Test public void Add_int_fixed_pad_2() {tst_Add_int_fixed(2, 2, "02");}
@Test public void Add_int_fixed_pad_16() {tst_Add_int_fixed(2, 16, "0000000000000002");} // test overflows int
@Test public void Add_int_fixed_neg() {tst_Add_int_fixed(-2, 2, "-2");}
@Test public void Add_int_fixed_neg_pad1() {tst_Add_int_fixed(-2, 1, "-");}
@Test public void Add_int_fixed_chop_1() {tst_Add_int_fixed(123, 1, "3");}
@Test public void Add_int_fixed_chop_neg() {tst_Add_int_fixed(-21, 2, "-1");}
void tst_Add_int_fixed(int val, int digits, String expd) {Tfds.Eq(expd, String_.new_u8(bb.Add_int_fixed(val, digits).To_bry()));}
@Test public void Add_long_fixed_len3() {tst_Add_long_fixed(123, 3, "123");}
@Test public void Add_long_fixed_pad_1() {tst_Add_long_fixed(2, 1, "2");}
@Test public void Add_long_fixed_pad_2() {tst_Add_long_fixed(2, 2, "02");}
@Test public void Add_long_fixed_pad_16() {tst_Add_long_fixed(2, 16, "0000000000000002");} // test overflows long
@Test public void Add_long_fixed_neg() {tst_Add_long_fixed(-2, 2, "-2");}
@Test public void Add_long_fixed_neg_pad1() {tst_Add_long_fixed(-2, 1, "-");}
@Test public void Add_long_fixed_chop_1() {tst_Add_long_fixed(123, 1, "3");}
@Test public void Add_long_fixed_chop_neg() {tst_Add_long_fixed(-21, 2, "-1");}
@Test public void Add_long_fixed_large() {tst_Add_long_fixed(123456789012345L, 15, "123456789012345");}
@Test public void Add_long_fixed_len3() {tst_Add_long_fixed(123, 3, "123");}
@Test public void Add_long_fixed_pad_1() {tst_Add_long_fixed(2, 1, "2");}
@Test public void Add_long_fixed_pad_2() {tst_Add_long_fixed(2, 2, "02");}
@Test public void Add_long_fixed_pad_16() {tst_Add_long_fixed(2, 16, "0000000000000002");} // test overflows long
@Test public void Add_long_fixed_neg() {tst_Add_long_fixed(-2, 2, "-2");}
@Test public void Add_long_fixed_neg_pad1() {tst_Add_long_fixed(-2, 1, "-");}
@Test public void Add_long_fixed_chop_1() {tst_Add_long_fixed(123, 1, "3");}
@Test public void Add_long_fixed_chop_neg() {tst_Add_long_fixed(-21, 2, "-1");}
@Test public void Add_long_fixed_large() {tst_Add_long_fixed(123456789012345L, 15, "123456789012345");}
void tst_Add_long_fixed(long val, int digits, String expd) {Tfds.Eq(expd, String_.new_u8(bb.Add_long_fixed(val, digits).To_bry()));}
@Test public void AddDte_short() {
@Test public void AddDte_short() {
tst_AddDte_short("2010-08-26T22:38:36Z");
}
void tst_AddDte_short(String raw) {
@ -111,7 +111,7 @@ public class Bry_bfr_tst {
//// Base85_.Set_bry(l, bb.
// bb.Add_int(l);
}
// @Test public void InsertAt_str() {
// @Test public void InsertAt_str() {
// tst_InsertAt_str("", 0, "c", "c");
// tst_InsertAt_str("ab", 0, "c", "cab");
// tst_InsertAt_str("ab", 0, "cdefghij", "cdefghijab");
@ -123,7 +123,7 @@ public class Bry_bfr_tst {
// String actl = bb.To_str_and_clear();
// Tfds.Eq(expd, actl);
// }
@Test public void To_bry_and_clear_and_trim() {
@Test public void To_bry_and_clear_and_trim() {
tst_XtoAryAndClearAndTrim("a" , "a");
tst_XtoAryAndClearAndTrim(" a " , "a");
tst_XtoAryAndClearAndTrim(" a b " , "a b");
@ -133,7 +133,7 @@ public class Bry_bfr_tst {
bb.Add_str_u8(raw);
Tfds.Eq(expd, String_.new_u8(bb.To_bry_and_clear_and_trim()));
}
@Test public void XtoInt() {
@Test public void XtoInt() {
tst_XtoInt("123", 123);
tst_XtoInt("a", Int_.Min_value);
tst_XtoInt("9999999999", Int_.Min_value);
@ -160,14 +160,14 @@ public class Bry_bfr_tst {
int second = (int)((v ) & 0x3f);
return DateAdp_.new_(year, month, day, hour, minute, second, 0);
}
@Test public void Add_bfr_trimEnd_and_clear() {
@Test public void Add_bfr_trimEnd_and_clear() {
tst_Add_bfr_trimEnd_and_clear("a ", "a");
}
void tst_Add_bfr_trimEnd_and_clear(String raw, String expd) {
Bry_bfr tmp = Bry_bfr_.New().Add_str_u8(raw);
Tfds.Eq(expd, bb.Add_bfr_trim_and_clear(tmp, false, true).To_str_and_clear());
}
@Test public void Add_bfr_trimAll_and_clear() {
@Test public void Add_bfr_trimAll_and_clear() {
tst_Add_bfr_trimAll_and_clear(" a ", "a");
tst_Add_bfr_trimAll_and_clear(" a b ", "a b");
tst_Add_bfr_trimAll_and_clear("a", "a");
@ -177,49 +177,49 @@ public class Bry_bfr_tst {
Bry_bfr tmp = Bry_bfr_.New().Add_str_u8(raw);
Tfds.Eq(expd, bb.Add_bfr_trim_and_clear(tmp, true, true).To_str_and_clear());
}
@Test public void Add_int_pad_bgn() {
@Test public void Add_int_pad_bgn() {
fxt.Test_Add_int_pad_bgn(Byte_ascii.Num_0, 3, 0, "000");
fxt.Test_Add_int_pad_bgn(Byte_ascii.Num_0, 3, 1, "001");
fxt.Test_Add_int_pad_bgn(Byte_ascii.Num_0, 3, 10, "010");
fxt.Test_Add_int_pad_bgn(Byte_ascii.Num_0, 3, 100, "100");
fxt.Test_Add_int_pad_bgn(Byte_ascii.Num_0, 3, 1000, "1000");
}
@Test public void Add_bry_escape() {
@Test public void Add_bry_escape() {
fxt.Test__add_bry_escape("abc" , "abc"); // nothing to escape
fxt.Test__add_bry_escape("a'bc" , "a''bc"); // single escape (code handles first quote differently)
fxt.Test__add_bry_escape("a'b'c" , "a''b''c"); // double escape (code handles subsequent quotes different than first)
fxt.Test__add_bry_escape("abc", 1, 2 , "b"); // nothing to escape
}
@Test public void Add_bry_escape_html() {
@Test public void Add_bry_escape_html() {
fxt.Test__add_bry_escape_html("abc" , "abc"); // escape=none
fxt.Test__add_bry_escape_html("a&\"'<>b" , "a&amp;&quot;&#39;&lt;&gt;b"); // escape=all; code handles first escape differently
fxt.Test__add_bry_escape_html("a&b&c" , "a&amp;b&amp;c"); // staggered; code handles subsequent escapes differently
fxt.Test__add_bry_escape_html("abc", 1, 2 , "b"); // by index; fixes bug in initial implementation
}
@Test public void Insert_at() {
@Test public void Insert_at() {
fxt.Test_Insert_at("abcd", 0, "xyz" , "xyzabcd"); // bgn
fxt.Test_Insert_at("abcd", 4, "xyz" , "abcdxyz"); // end
fxt.Test_Insert_at("abcd", 2, "xyz" , "abxyzcd"); // mid
fxt.Test_Insert_at("abcd", 2, "xyz", 1, 2 , "abycd"); // mid
}
@Test public void Delete_rng() {
@Test public void Delete_rng() {
fxt.Test_Delete_rng("abcd", 0, 2 , "cd"); // bgn
fxt.Test_Delete_rng("abcd", 2, 4 , "ab"); // end
fxt.Test_Delete_rng("abcd", 1, 3 , "ad"); // mid
}
@Test public void Delete_rng_to_bgn() {
@Test public void Delete_rng_to_bgn() {
fxt.Test_Delete_rng_to_bgn("abcd", 2 , "cd");
}
@Test public void Delete_rng_to_end() {
@Test public void Delete_rng_to_end() {
fxt.Test_Delete_rng_to_end("abcd", 2 , "ab");
}
@Test public void To_bry_ary_and_clear() {
@Test public void To_bry_ary_and_clear() {
fxt.Test__to_bry_ary_and_clear("" ); // empty
fxt.Test__to_bry_ary_and_clear("a" , "a"); // lines=1
fxt.Test__to_bry_ary_and_clear("a\nb\nc" , "a", "b", "c"); // lines=n
fxt.Test__to_bry_ary_and_clear("a\n" , "a"); // nl at end
}
@Test public void To_bry_ary_and_clear_and_trim__memory_reference_bug() {// PURPOSE:test that bry isn't reused; ISSUE#:562; DATE:2019-09-02
@Test public void To_bry_ary_and_clear_and_trim__memory_reference_bug() {// PURPOSE:test that bry isn't reused; ISSUE#:562; DATE:2019-09-02
String str_a = "aaaaaaaaaaaaaaaa" // NOTE: length is 16 b/c bry_bfr init's to 16 len
, str_b = "bbbbbbbbbbbbbbbb";
Bry_bfr bfr = Bry_bfr_.New();

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class Bry_find_ {
public static final int Not_found = -1;
@ -230,6 +230,12 @@ public class Bry_find_ {
--cur;
}
}
public static int Find_bwd_while_in(byte[] src, int cur, int end, boolean[] while_ary) {
while (true) {
if (cur <= end || !while_ary[src[cur]]) return cur;
cur--;
}
}
public static int Find_bwd_while_v2(byte[] src, int cur, int end, byte while_byte) {
--cur;
while (true) {

@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*; import gplx.core.tests.*;
public class Bry_find__tst {
private Bry_find__fxt fxt = new Bry_find__fxt();
@Test public void Find_fwd() {
@Test public void Find_fwd() {
fxt.Test_Find_fwd("abcba", "b", 0, 1);
fxt.Test_Find_fwd("abcba", "z", 0, -1);
fxt.Test_Find_fwd("abcba", "b", 1, 1);
@ -26,7 +26,7 @@ public class Bry_find__tst {
fxt.Test_Find_fwd("abcba", "zb", 4, -1);
fxt.Test_Find_fwd("abcba", "a", 6, -1);
}
@Test public void Find_bwd() {
@Test public void Find_bwd() {
fxt.Test_Find_bwd("abcba", "b", 4, 3);
fxt.Test_Find_bwd("abcba", "z", 4, -1);
fxt.Test_Find_bwd("abcba", "b", 3, 1);
@ -36,12 +36,12 @@ public class Bry_find__tst {
fxt.Test_Find_fwd("abcba", "a", -1, -1);
fxt.Test_Find_bwd("abcba", "ab", 4, 0);
}
@Test public void Find_bwd_last_ws() {
@Test public void Find_bwd_last_ws() {
fxt.Test_Find_bwd_1st_ws_tst("a b" , 2, 1); // basic
fxt.Test_Find_bwd_1st_ws_tst("a b" , 3, 1); // multiple
fxt.Test_Find_bwd_1st_ws_tst("ab" , 1, Bry_find_.Not_found); // none
}
@Test public void Trim_fwd_space_tab() {
@Test public void Trim_fwd_space_tab() {
fxt.Test_Trim_fwd_space_tab(" a b" , 1);
fxt.Test_Trim_fwd_space_tab("\ta b" , 1);
fxt.Test_Trim_fwd_space_tab(" \ta b" , 2);
@ -49,7 +49,7 @@ public class Bry_find__tst {
fxt.Test_Trim_fwd_space_tab("" , 0);
fxt.Test_Trim_fwd_space_tab(" \t" , 2);
}
@Test public void Trim_bwd_space_tab() {
@Test public void Trim_bwd_space_tab() {
fxt.Test_Trim_bwd_space_tab("a b " , 3);
fxt.Test_Trim_bwd_space_tab("a b\t" , 3);
fxt.Test_Trim_bwd_space_tab("a b\t " , 3);
@ -57,7 +57,7 @@ public class Bry_find__tst {
fxt.Test_Trim_bwd_space_tab("" , 0);
fxt.Test_Trim_bwd_space_tab(" \t" , 0);
}
@Test public void Find_fwd_while_in() {
@Test public void Find_fwd_while_in() {
boolean[] while_ary = fxt.Init__find_fwd_while_in(Byte_ascii.Space, Byte_ascii.Tab, Byte_ascii.Nl);
fxt.Test__find_fwd_while_in(" \t\na", while_ary, 3);
}

@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*; import gplx.core.tests.*;
public class Bry_split__tst {
private final Bry_split__fxt fxt = new Bry_split__fxt();
@Test public void Split() {
@Test public void Split() {
fxt.Test_split("a" , Byte_ascii.Pipe, Bool_.N, "a"); // no trim
fxt.Test_split("a|" , Byte_ascii.Pipe, Bool_.N, "a");
fxt.Test_split("|a" , Byte_ascii.Pipe, Bool_.N, "", "a");
@ -37,19 +37,19 @@ public class Bry_split__tst {
fxt.Test_split("extend|a" , Byte_ascii.Pipe, Bool_.Y, "extend|a"); // extend
fxt.Test_split("a|cancel|b" , Byte_ascii.Pipe, Bool_.Y, "a"); // cancel
}
@Test public void Split__bry() {
@Test public void Split__bry() {
fxt.Test_split("a|b|c|d" , 2, 6, "|", "b", "c");
fxt.Test_split("a|b|c|d" , 2, 4, "|", "b");
}
@Test public void Empty() {
@Test public void Empty() {
fxt.Test_split("a\n\nb" , Byte_ascii.Nl, Bool_.N, "a", "", "b");
}
@Test public void Split_w_max() {
@Test public void Split_w_max() {
fxt.Test__split_w_max("a|b|c|d" , Byte_ascii.Pipe, 2, "a", "b"); // max is less
fxt.Test__split_w_max("a" , Byte_ascii.Pipe, 2, "a", null); // max is more
fxt.Test__split_w_max("|" , Byte_ascii.Pipe, 2, "", ""); // empty itms
}
@Test public void Split_ws() {
@Test public void Split_ws() {
fxt.Test__split_ws("a b", "a", "b");
fxt.Test__split_ws(" a ", "a");
fxt.Test__split_ws(" abc def ", "abc", "def");

@ -1,29 +1,29 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;
public class Byte__tst {
@Test public void int_() {
@Test public void int_() {
tst_int_( 0, 0);
tst_int_( 127, 127);
tst_int_( 128, 128); // NOTE: JAVA defines byte as -128 -> 127
tst_int_( 255, 255);
tst_int_( 256, 0); // NOTE: 256 will cast to 1; (byte)256 works same in both JAVA/.NET
} void tst_int_(int v, int expd) {Tfds.Eq((byte)expd, Byte_.By_int(v));} // WORKAROUND/JAVA: expd is of type int b/c java promotes numbers to ints
@Test public void To_int() {
@Test public void To_int() {
tst_XtoInt( 0, 0);
tst_XtoInt( 127, 127);
tst_XtoInt( 128, 128);

@ -1,19 +1,20 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.times.DateAdp_parser;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@ -22,7 +23,6 @@ import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone;
import gplx.core.times.*;
public class DateAdp_ implements Gfo_invk {
public static final String Cls_ref_name = "Date";
public static final Class<?> Cls_ref_type = DateAdp.class;
@ -84,8 +84,11 @@ public class DateAdp_ implements Gfo_invk {
try {return parse_fmt(raw, fmt);}
catch (Exception e) {Err_.Noop(e); return or;}
}
public static DateAdp db_(Object v) {
Timestamp ts = (Timestamp)v;
public static DateAdp db_(Object v) {
if (v instanceof String) {
return DateAdp_.parse_iso8561((String)v);
}
Timestamp ts = (Timestamp)v;
Calendar gc = Calendar.getInstance();
gc.setTimeInMillis(ts.getTime());
return new DateAdp(gc);

@ -1,40 +1,40 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*; import gplx.core.tests.*;
public class DateAdp__tst {
private final DateAdp__fxt fxt = new DateAdp__fxt();
@Test public void Parse_gplx() {
@Test public void Parse_gplx() {
fxt.Test__parse_gplx("99991231_235959.999" , "99991231_235959.999");
fxt.Test__parse_gplx("20090430_213200.123" , "20090430_213200.123");
fxt.Test__parse_gplx("20090430_213200" , "20090430_213200.000");
fxt.Test__parse_gplx("20090430" , "20090430_000000.000");
}
@Test public void Parse_separators() {
@Test public void Parse_separators() {
fxt.Test__parse_gplx("2009-04-30 21:32:00.123" , "20090430_213200.123");
fxt.Test__parse_gplx("2009-04-30 21:32:00" , "20090430_213200.000");
fxt.Test__parse_gplx("2009-04-30" , "20090430_000000.000");
}
@Test public void Parse_utc() {
@Test public void Parse_utc() {
fxt.Test__parse_gplx("2015-12-26T10:03:53Z" , "20151226_100353.000");
}
@Test public void DayOfWeek() {
@Test public void DayOfWeek() {
fxt.Test__day_of_week("2012-01-18", 3); //3=Wed
}
@Test public void WeekOfYear() {
@Test public void WeekOfYear() {
fxt.Test__week_of_year("2006-02-01", 5); // 1-1:Sun;2-1:Wed
fxt.Test__week_of_year("2007-02-01", 5); // 1-1:Mon;2-1:Thu
fxt.Test__week_of_year("2008-02-01", 5); // 1-1:Tue;2-1:Fri
@ -42,25 +42,25 @@ public class DateAdp__tst {
fxt.Test__week_of_year("2010-02-01", 6); // 1-1:Fri;2-1:Mon
fxt.Test__week_of_year("2011-02-01", 6); // 1-1:Sat;2-1:Tue
}
@Test public void DayOfYear() {
@Test public void DayOfYear() {
fxt.Test__day_of_year("2012-01-01", 1);
fxt.Test__day_of_year("2012-02-29", 60);
fxt.Test__day_of_year("2012-12-31", 366);
}
@Test public void Timestamp_unix() {
@Test public void Timestamp_unix() {
fxt.Test__timestamp_unix("1970-01-01 00:00:00", 0);
fxt.Test__timestamp_unix("2012-01-01 00:00:00", 1325376000);
}
@Test public void DaysInMonth() {
@Test public void DaysInMonth() {
fxt.Test__days_in_month("2012-01-01", 31);
fxt.Test__days_in_month("2012-02-01", 29);
fxt.Test__days_in_month("2012-04-01", 30);
fxt.Test__days_in_month("2011-02-01", 28);
}
@Test public void XtoUtc() {
@Test public void XtoUtc() {
fxt.Test__to_utc("2012-01-01 00:00", "2012-01-01 05:00"); //4=Wed
}
@Test public void Timezone_id() {
@Test public void Timezone_id() {
fxt.Test__timezone_id("2015-12-26T10:03:53Z", "UTC");
}
}

@ -13,15 +13,15 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;
public class Double__tst {
private Double__fxt fxt = new Double__fxt();
@Test public void Xto_str_loose() {
fxt.Test_Xto_str_loose(2449.6000000d , "2449.6");
fxt.Test_Xto_str_loose(623.700d , "623.7");
}
}
class Double__fxt {
public void Test_Xto_str_loose(double v, String expd) {Tfds.Eq(expd, Double_.To_str_loose(v));}
}
package gplx;
import org.junit.*;
public class Double__tst {
private Double__fxt fxt = new Double__fxt();
@Test public void Xto_str_loose() {
fxt.Test_Xto_str_loose(2449.6000000d , "2449.6");
fxt.Test_Xto_str_loose(623.700d , "623.7");
}
}
class Double__fxt {
public void Test_Xto_str_loose(double v, String expd) {Tfds.Eq(expd, Double_.To_str_loose(v));}
}

@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;
public class Err_tst {
private final Err_fxt fxt = new Err_fxt();
@Test public void Trace_to_str__gplx() {
@Test public void Trace_to_str__gplx() {
fxt.Test_Trace_to_str(Bool_.Y, Bool_.N, 0, String_.Concat_lines_nl_skip_last
( "gplx.Err_.new_wo_type(Err_.java:1)" // ignore this line
, "gplx.String_.Len(String_.java:2)"
@ -26,7 +26,7 @@ public class Err_tst {
, " gplx.String_.Len(String_.java:2)"
));
}
@Test public void Trace_to_str__gplx_ignore() {
@Test public void Trace_to_str__gplx_ignore() {
fxt.Test_Trace_to_str(Bool_.Y, Bool_.N, 1, String_.Concat_lines_nl_skip_last
( "gplx.Err_.new_wo_type(Err_.java:1)" // ignore this line
, "gplx.String_.Fail(String_.java:2)" // ignore this line also

@ -1,29 +1,29 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*; import gplx.langs.gfs.*;
public class GfoMsg_tst {
@Before public void setup() {
GfsCore.Instance.AddObj(new Mok(), "Mok");
}
@Test public void Write1() {
@Test public void Write1() {
GfoMsg m = GfoMsg_.root_leafArgs_(String_.Ary("a", "b"), Keyval_.new_("int0", 1));
tst_Msg(m, "a.b:int0='1';");
}
@Test public void Write() {
@Test public void Write() {
Mok mok = new Mok();
tst_Msg(Gfo_invk_to_str.WriteMsg(mok, Mok.Invk_Cmd0, true, 1, "a"), "Mok.Cmd0:bool0='y' int0='1' str0='a';");
mok.Int0 = 2;

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.lists.*;
public class Gfo_evt_mgr {

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class Gfo_evt_mgr_ {
public static void Sub(Gfo_evt_mgr_owner pub, String pubEvt, Gfo_evt_itm sub, String subEvt) {pub.Evt_mgr().AddSub(pub, pubEvt, sub, subEvt);}

@ -1,49 +1,49 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;
public class Gfo_evt_mgr_tst {
@Before public void setup() {
pub = make_(); sub = make_();
} MockEvObj pub, sub;
@Test public void Basic() {
@Test public void Basic() {
Gfo_evt_mgr_.Sub_same(pub, "ev1", sub);
Gfo_evt_mgr_.Pub_val(pub, "ev1", "val1");
sub.tst_Handled("val1");
}
@Test public void None() {// make sure no subscribers does not cause exception
@Test public void None() {// make sure no subscribers does not cause exception
Gfo_evt_mgr_.Sub_same(pub, "ev1", sub);
Gfo_evt_mgr_.Pub_val(pub, "ev2", "val1"); //ev2 does not exist
sub.tst_Handled();
}
@Test public void Lnk() {
@Test public void Lnk() {
MockEvObj mid = make_();
mid.Evt_mgr().Lnk(pub);
Gfo_evt_mgr_.Sub_same(mid, "ev1", sub);
Gfo_evt_mgr_.Pub_val(pub, "ev1", "val1");
sub.tst_Handled("val1");
}
@Test public void RlsSub() {
@Test public void RlsSub() {
this.Basic();
Gfo_evt_mgr_.Rls_sub(sub);
Gfo_evt_mgr_.Pub_val(pub, "ev1", "val1");
sub.tst_Handled();
}
@Test public void RlsPub() {
@Test public void RlsPub() {
this.Basic();
Gfo_evt_mgr_.Rls_sub(pub);

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.core.primitives.*;
public class Gfo_invk_ {
@ -23,7 +23,9 @@ public class Gfo_invk_ {
, Rv_handled = String_obj_val.new_("Handled")
, Rv_host = String_obj_val.new_("Host")
, Rv_cancel = String_obj_val.new_("Cancel")
, Rv_error = String_obj_val.new_("Error");
, Rv_error = String_obj_val.new_("Error")
, ArgNone = String_obj_val.new_("")
;
public static Gfo_invk as_(Object obj) {return obj instanceof Gfo_invk ? (Gfo_invk)obj : null;}

@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import gplx.langs.gfs.*;
public class Gfo_invk_to_str {
public static GfoMsg ReadMsg(Gfo_invk invk, String k) {
GfsCtx ctx = GfsCtx.wtr_();
GfsCtx ctx = GfsCtx.NewDeny();
GfoMsg m = GfoMsg_.rdr_(k);
invk.Invk(ctx, 0, k, m);
String invkKey = GfsCore.Instance.FetchKey(invk);
@ -27,7 +27,7 @@ public class Gfo_invk_to_str {
}
public static GfoMsg WriteMsg(Gfo_invk invk, String k, Object... ary) {return WriteMsg(GfsCore.Instance.FetchKey(invk), invk, k, ary);}
public static GfoMsg WriteMsg(String invkKey, Gfo_invk invk, String k, Object... ary) {
GfsCtx ctx = GfsCtx.wtr_();
GfsCtx ctx = GfsCtx.NewDeny();
GfoMsg m = GfoMsg_.wtr_();
invk.Invk(ctx, 0, k, m);
GfoMsg rv = GfoMsg_.new_cast_(k);

@ -1,6 +1,6 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
Copyright (C) 2012-2021 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
@ -13,51 +13,19 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class GfsCtx {
public Ordered_hash Vars() {return vars;} Ordered_hash vars = Ordered_hash_.New();
public boolean Fail_if_unhandled() {return fail_if_unhandled;} public GfsCtx Fail_if_unhandled_(boolean v) {fail_if_unhandled = v; return this;} private boolean fail_if_unhandled;
public Gfo_usr_dlg Usr_dlg() {return usr_dlg;} public GfsCtx Usr_dlg_(Gfo_usr_dlg v) {usr_dlg = v; return this;} Gfo_usr_dlg usr_dlg;
public boolean Help_browseMode() {return help_browseMode;} public GfsCtx Help_browseMode_(boolean v) {help_browseMode = v; return this;} private boolean help_browseMode;
public List_adp Help_browseList() {return help_browseList;} List_adp help_browseList = List_adp_.New();
public Object MsgSrc() {return msgSrc;} public GfsCtx MsgSrc_(Object v) {msgSrc = v; return this;} Object msgSrc;
public boolean Match(String k, String match) {
if (help_browseMode) {
help_browseList.Add(match);
return false;
}
else
return String_.Eq(k, match);
}
public boolean MatchPriv(String k, String match) {return help_browseMode ? false : String_.Eq(k, match);}
public boolean MatchIn(String k, String... match) {
if (help_browseMode) {
for (String i : match)
help_browseList.Add(i);
return false;
}
return String_.In(k, match);
}
public boolean Write_note(String fmt, Object... ary) {UsrDlg_.Instance.Note(fmt, ary); return false;}
public boolean Write_warn(String fmt, Object... ary) {UsrDlg_.Instance.Note("! " + fmt, ary); return false;}
public boolean Write_stop(UsrMsg umsg) {UsrDlg_.Instance.Note("* " + umsg.To_str()); return false;}
public boolean Write_stop(String fmt, Object... ary) {UsrDlg_.Instance.Note("* " + fmt, ary); return false;}
public boolean Deny() {return deny;} private boolean deny;
public static final GfsCtx Instance = new GfsCtx();
public static GfsCtx new_() {return new GfsCtx();} GfsCtx() {}
public static GfsCtx rdr_() {
GfsCtx rv = new GfsCtx();
rv.deny = true;
rv.mode = "read";
return rv;
}
public static GfsCtx wtr_() {
GfsCtx rv = new GfsCtx();
rv.deny = true;
rv.mode = Mode_write;
return rv;
}
public String Mode() {return mode;} public GfsCtx Mode_(String v) {mode = v; return this;} private String mode = "regular";
public static final String Mode_write = "write";
public static final int Ikey_null = -1;
}
package gplx;
public class GfsCtx {
private GfsCtx(boolean deny) {
this.deny = deny;
}
public Object MsgSrc() {return msgSrc;} public GfsCtx MsgSrc_(Object v) {msgSrc = v; return this;} private Object msgSrc;
public boolean Fail_if_unhandled() {return fail_if_unhandled;} public GfsCtx Fail_if_unhandled_(boolean v) {fail_if_unhandled = v; return this;} private boolean fail_if_unhandled;
public boolean Deny() {return deny;} private final boolean deny;
public boolean Match(String k, String match) {return String_.Eq(k, match);}
public boolean MatchPriv(String k, String match) {return String_.Eq(k, match);}
public boolean MatchIn(String k, String... match) {return String_.In(k, match);}
public static final GfsCtx Instance = new_();
public static GfsCtx new_() {return new GfsCtx(false);}
public static GfsCtx NewDeny() {return new GfsCtx(true);}
}

@ -13,14 +13,14 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;
public class Guid_adp__tst {
@Test public void parse() {
tst_parse_("467ffb41-cdfe-402f-b22b-be855425784b");
}
void tst_parse_(String s) {
Guid_adp uuid = Guid_adp_.Parse(s);
Tfds.Eq(uuid.To_str(), s);
}
}
package gplx;
import org.junit.*;
public class Guid_adp__tst {
@Test public void parse() {
tst_parse_("467ffb41-cdfe-402f-b22b-be855425784b");
}
void tst_parse_(String s) {
Guid_adp uuid = Guid_adp_.Parse(s);
Tfds.Eq(uuid.To_str(), s);
}
}

@ -1,36 +1,36 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;
public class Hash_adp_bry_tst {
@Before public void setup() {fxt.Clear();} private Hash_adp_bry_fxt fxt = new Hash_adp_bry_fxt();
@Test public void Add_bry() {
@Test public void Add_bry() {
fxt .New_cs()
.Add("a0").Add("b0").Add("c0")
.Get_bry_tst("a0").Get_bry_tst("b0").Get_bry_tst("c0").Get_bry_tst("A0", null)
;
}
@Test public void Get_mid() {
@Test public void Get_mid() {
fxt .New_cs()
.Add("a0").Add("b0").Add("c0")
.Get_mid_tst("xyza0xyz", 3, 5, "a0")
.Get_mid_tst("xyza0xyz", 3, 4, null)
;
}
@Test public void Case_insensitive() {
@Test public void Case_insensitive() {
fxt .New_ci()
.Add("a0").Add("B0").Add("c0")
.Get_bry_tst("a0", "a0")

@ -1,22 +1,22 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;
public class Int__tst {
@Test public void XtoStr_PadBgn() {
@Test public void XtoStr_PadBgn() {
tst_XtoStr_PadLeft_Zeroes(1 , 3, "001"); // pad
tst_XtoStr_PadLeft_Zeroes(123 , 3, "123"); // no pad
tst_XtoStr_PadLeft_Zeroes(1234 , 3, "1234"); // val exceeds pad; confirm noop
@ -25,11 +25,11 @@ public class Int__tst {
tst_XtoStr_PadLeft_Zeroes(-123 , 3, "-123"); // negative
tst_XtoStr_PadLeft_Zeroes(-1234 , 3, "-1234"); // negative
} void tst_XtoStr_PadLeft_Zeroes(int val, int zeros, String expd) {Tfds.Eq(expd, Int_.To_str_pad_bgn_zero(val, zeros));}
@Test public void Xto_fmt() {
@Test public void Xto_fmt() {
tst_XtoStr_fmt(1, "1");
tst_XtoStr_fmt(1000, "1,000");
} void tst_XtoStr_fmt(int v, String expd) {Tfds.Eq(expd, Int_.To_str_fmt(v, "#,###"));}
@Test public void Xto_int_hex_tst() {
@Test public void Xto_int_hex_tst() {
Xto_int_hex("007C", 124);
} void Xto_int_hex(String raw, int expd) {Tfds.Eq(expd, Int_.By_hex_bry(Bry_.new_a7(raw)));}
}

@ -1,24 +1,24 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*; import gplx.core.tests.*;
public class Int_ary__tst {
private Int_ary__fxt fxt = new Int_ary__fxt();
@Test public void Parse() {
@Test public void Parse() {
fxt.Test__Parse("1,2,3" , 3, Int_ary_.Empty, 1, 2, 3);
fxt.Test__Parse("123,321,213" , 3, Int_ary_.Empty, 123, 321, 213);
fxt.Test__Parse(" 1, 2,3" , 3, Int_ary_.Empty, 1, 2, 3);
@ -31,7 +31,7 @@ public class Int_ary__tst {
fxt.Test__Parse("1-2," , 1, Int_ary_.Empty);
}
@Test public void Parse_list_or_() {
@Test public void Parse_list_or_() {
fxt.Test__Parse_or("1", 1);
fxt.Test__Parse_or("123", 123);
fxt.Test__Parse_or("1,2,123", 1, 2, 123);

@ -1,28 +1,28 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;
public class Io_mgr__tst {
@Before public void init() {fxt.Clear();} private final Io_mgr__fxt fxt = new Io_mgr__fxt();
@Test public void Dir_delete_empty__basic() {
@Test public void Dir_delete_empty__basic() {
fxt.Exec_itm_create("mem/dir/");
fxt.Exec_dir_delete_empty("mem/dir/");
fxt.Test_itm_exists_n("mem/dir/");
}
@Test public void Dir_delete_empty__no_delete() {
@Test public void Dir_delete_empty__no_delete() {
fxt.Exec_itm_create
( "mem/dir/"
, "mem/dir/fil.txt"
@ -30,7 +30,7 @@ public class Io_mgr__tst {
fxt.Exec_dir_delete_empty("mem/dir/");
fxt.Test_itm_exists_y("mem/dir/");
}
@Test public void Dir_delete_empty__nested_simple() {
@Test public void Dir_delete_empty__nested_simple() {
fxt.Exec_itm_create
( "mem/dir/"
, "mem/dir/1/"
@ -39,7 +39,7 @@ public class Io_mgr__tst {
fxt.Exec_dir_delete_empty("mem/dir/");
fxt.Test_itm_exists_n("mem/dir/");
}
@Test public void Dir_delete_empty__nested_many() {
@Test public void Dir_delete_empty__nested_many() {
fxt.Exec_itm_create
( "mem/dir/"
, "mem/dir/1/"
@ -51,7 +51,7 @@ public class Io_mgr__tst {
fxt.Exec_dir_delete_empty("mem/dir/");
fxt.Test_itm_exists_n("mem/dir/");
}
@Test public void Dir_delete_empty__nested_some() {
@Test public void Dir_delete_empty__nested_some() {
fxt.Exec_itm_create
( "mem/dir/"
, "mem/dir/1/"

@ -1,32 +1,32 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*; import gplx.core.tests.*; import gplx.core.envs.*;
public class Io_url__tst {
@Before public void init() {fxt.Clear();} private final Io_url__fxt fxt = new Io_url__fxt();
@Test public void Basic__lnx() {fxt.Test__New__http_or_null(Bool_.N, "file:///C:/a.txt", "C:/a.txt");}
@Test public void Basic__wnt() {fxt.Test__New__http_or_null(Bool_.Y, "file:///C:/a.txt", "C:\\a.txt");}
@Test public void Null() {fxt.Test__New__http_or_null(Bool_.N, "C:/a.txt", null);}
}
class Io_url__fxt {
public void Clear() {Io_mgr.Instance.InitEngine_mem();}
public void Test__New__http_or_null(boolean os_is_wnt, String raw, String expd) {
int curTid = Op_sys.Cur().Tid();
Op_sys.Cur_(os_is_wnt ? Op_sys.Tid_wnt : Op_sys.Tid_lnx);
Gftest.Eq__obj_or_null(expd, Io_url_.New__http_or_null(raw));
Op_sys.Cur_(curTid);
}
}
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*; import gplx.core.tests.*; import gplx.core.envs.*;
public class Io_url__tst {
@Before public void init() {fxt.Clear();} private final Io_url__fxt fxt = new Io_url__fxt();
@Test public void Basic__lnx() {fxt.Test__New__http_or_null(Bool_.N, "file:///C:/a.txt", "C:/a.txt");}
@Test public void Basic__wnt() {fxt.Test__New__http_or_null(Bool_.Y, "file:///C:/a.txt", "C:\\a.txt");}
@Test public void Null() {fxt.Test__New__http_or_null(Bool_.N, "C:/a.txt", null);}
}
class Io_url__fxt {
public void Clear() {Io_mgr.Instance.InitEngine_mem();}
public void Test__New__http_or_null(boolean os_is_wnt, String raw, String expd) {
int curTid = Op_sys.Cur().Tid();
Op_sys.Cur_(os_is_wnt ? Op_sys.Tid_wnt : Op_sys.Tid_lnx);
Gftest.Eq__obj_or_null(expd, Io_url_.New__http_or_null(raw));
Op_sys.Cur_(curTid);
}
}

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;
public class List_adp_tst {
@ -20,13 +20,13 @@ public class List_adp_tst {
list = List_adp_.New();
listBase = (List_adp_base)list;
} List_adp list; List_adp_base listBase;
@Test public void Add() {
@Test public void Add() {
Tfds.Eq(0, list.Count());
list.Add("0");
Tfds.Eq(1, list.Count());
}
@Test public void Add_changeCapacity() {
@Test public void Add_changeCapacity() {
int capacity = 8;
for (int i = 0; i < capacity; i++)
list.Add("0");
@ -37,30 +37,30 @@ public class List_adp_tst {
Tfds.Eq(capacity + 1, list.Count());
Tfds.Eq(capacity * 2, listBase.Capacity());
}
@Test public void Get_at() {
@Test public void Get_at() {
list.Add("0");
Tfds.Eq("0", list.Get_at(0));
}
@Test public void Fetch_many() {
@Test public void Fetch_many() {
list_AddMany("0", "1");
Tfds.Eq("0", list.Get_at(0));
Tfds.Eq("1", list.Get_at(1));
}
@Test public void FetchAt_fail() {
@Test public void FetchAt_fail() {
try {list.Get_at(0);}
catch (Exception exc) {Err_.Noop(exc); return;}
Tfds.Fail("Get_at should fail for out of bound index");
}
@Test public void Del_at() {
@Test public void Del_at() {
list.Add("0");
Tfds.Eq(1, list.Count());
list.Del_at(0);
Tfds.Eq(0, list.Count());
}
@Test public void DelAt_shiftDown() {
@Test public void DelAt_shiftDown() {
list_AddMany("0", "1");
Tfds.Eq(list.Count(), 2);
@ -68,19 +68,19 @@ public class List_adp_tst {
Tfds.Eq(1, list.Count());
Tfds.Eq("1", list.Get_at(0));
}
@Test public void DelAt_fail() {
@Test public void DelAt_fail() {
try {list.Del_at(0);}
catch (Exception exc) {Err_.Noop(exc); return;}
Tfds.Fail("Del_at should fail for out of bound index");
}
@Test public void Del() {
@Test public void Del() {
list.Add("0");
Tfds.Eq(1, list.Count());
list.Del("0");
Tfds.Eq(0, list.Count());
}
@Test public void Del_matchMember() {
@Test public void Del_matchMember() {
list_AddMany("0", "1");
Tfds.Eq(2, list.Count());
@ -88,23 +88,23 @@ public class List_adp_tst {
Tfds.Eq(1, list.Count());
Tfds.Eq("0", list.Get_at(0));
}
@Test public void Del_matchFirst() {
@Test public void Del_matchFirst() {
list_AddMany("0", "1", "0");
Tfds.Eq(3, list.Count());
list.Del("0");
tst_Enumerator("1", "0");
}
@Test public void Enumerator() {
@Test public void Enumerator() {
list_AddMany("0", "1", "2");
tst_Enumerator("0", "1", "2");
}
@Test public void Enumerator_stateLess() { // run 2x, to confirm no state is being cached
@Test public void Enumerator_stateLess() { // run 2x, to confirm no state is being cached
list_AddMany("0", "1", "2");
tst_Enumerator("0", "1", "2");
tst_Enumerator("0", "1", "2");
}
@Test public void Enumerator_recursive() { // confirm separate enumerator objects are used
@Test public void Enumerator_recursive() { // confirm separate enumerator objects are used
int pos = 0;
list_AddMany("0", "1", "2");
for (Object valObj : list) {
@ -113,7 +113,7 @@ public class List_adp_tst {
tst_Enumerator("0", "1", "2");
}
}
@Test public void Clear() {
@Test public void Clear() {
int capacity = 8;
for (int i = 0; i < capacity + 1; i++)
list.Add("0");
@ -123,36 +123,36 @@ public class List_adp_tst {
Tfds.Eq(0, list.Count());
Tfds.Eq(16, listBase.Capacity()); // check that capacity has increased
}
@Test public void Clear_empty() { // confirm no failure
@Test public void Clear_empty() { // confirm no failure
list.Clear();
Tfds.Eq(0, list.Count());
}
@Test public void Reverse() {
@Test public void Reverse() {
list_AddMany("0", "1", "2");
list.Reverse();
tst_Enumerator("2", "1", "0");
}
@Test public void Reverse_empty() {list.Reverse();}
@Test public void Sort() {
@Test public void Reverse_empty() {list.Reverse();}
@Test public void Sort() {
list_AddMany("2", "0", "1");
list.Sort();
tst_Enumerator("0", "1", "2");
}
@Test public void Sort_empty() {list.Sort();}
@Test public void Xto_bry() {
@Test public void Sort_empty() {list.Sort();}
@Test public void Xto_bry() {
list_AddMany("0", "1");
String[] ary = (String[])list.To_ary(String.class);
Tfds.Eq_nullNot(ary);
Tfds.Eq(2, Array_.Len(ary));
}
@Test public void XtoAry_empty() {
@Test public void XtoAry_empty() {
String[] ary = (String[])list.To_ary(String.class);
Tfds.Eq_nullNot(ary);
Tfds.Eq(0, Array_.Len(ary));
}
@Test public void Shuffle() {
@Test public void Shuffle() {
for (int i = 0; i < 25; i++)
list.Add(i);
@ -169,14 +169,14 @@ public class List_adp_tst {
list.Del(i);
Tfds.Eq(0, list.Count(), "shuffled list does not have the same contents as original list");
}
@Test public void Shuffle_empty() {list.Shuffle();}
@Test public void Move_to() {
@Test public void Shuffle_empty() {list.Shuffle();}
@Test public void Move_to() {
run_ClearAndAdd("0", "1", "2").run_MoveTo(0, 1).tst_Order("1", "0", "2");
run_ClearAndAdd("0", "1", "2").run_MoveTo(0, 2).tst_Order("1", "2", "0");
run_ClearAndAdd("0", "1", "2").run_MoveTo(2, 1).tst_Order("0", "2", "1");
run_ClearAndAdd("0", "1", "2").run_MoveTo(2, 0).tst_Order("2", "0", "1");
}
@Test public void Del_range() {
@Test public void Del_range() {
run_ClearAndAdd("0", "1", "2", "3").tst_DelRange(0, 2, "3");
run_ClearAndAdd("0", "1", "2", "3").tst_DelRange(0, 3);
run_ClearAndAdd("0", "1", "2", "3").tst_DelRange(1, 2, "0", "3");

@ -1,22 +1,22 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;
public class Long__tst {
@Test public void DigitCount() {
@Test public void DigitCount() {
tst_DigitCount(0, 1);
tst_DigitCount(1, 1);
tst_DigitCount(9, 1);
@ -31,7 +31,7 @@ public class Long__tst {
tst_DigitCount(10000000000000000L, 17);
tst_DigitCount(-1, 2);
} void tst_DigitCount(long val, int expd) {Tfds.Eq(expd, Long_.DigitCount(val));}
@Test public void Int_merge() {
@Test public void Int_merge() {
tst_Int_merge(123, 456, 528280977864L);
tst_Int_merge(123, 457, 528280977865L);
}
@ -40,7 +40,7 @@ public class Long__tst {
Tfds.Eq(hi, Long_.Int_split_hi(expd));
Tfds.Eq(lo, Long_.Int_split_lo(expd));
}
@Test public void parse_or() {
@Test public void parse_or() {
parse_or_tst("10000000000", 10000000000L);
}
void parse_or_tst(String raw, long expd) {Tfds.Eq(expd, Long_.parse_or(raw, -1));}

@ -1,47 +1,47 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;
public class Math__tst {
@Test public void Abs() {
@Test public void Abs() {
tst_Abs(1, 1);
tst_Abs(-1, 1);
tst_Abs(0, 0);
} void tst_Abs(int val, int expd) {Tfds.Eq(expd, Math_.Abs(val));}
@Test public void Log10() {
@Test public void Log10() {
tst_Log10(0, Int_.Min_value);
tst_Log10(9, 0);
tst_Log10(10, 1);
tst_Log10(99, 1);
tst_Log10(100, 2);
} void tst_Log10(int val, int expd) {Tfds.Eq(expd, Math_.Log10(val));}
@Test public void Min() {
@Test public void Min() {
tst_Min(0, 1, 0);
tst_Min(1, 0, 0);
tst_Min(0, 0, 0);
} void tst_Min(int val0, int val1, int expd) {Tfds.Eq(expd, Math_.Min(val0, val1));}
@Test public void Pow() {
@Test public void Pow() {
tst_Pow(2, 0, 1);
tst_Pow(2, 1, 2);
tst_Pow(2, 2, 4);
} void tst_Pow(int val, int exponent, double expd) {Tfds.Eq(expd, Math_.Pow(val, exponent));}
@Test public void Mult() {
@Test public void Mult() {
tst_Mult(100, .01f, 1);
} void tst_Mult(int val, float multiplier, int expd) {Tfds.Eq(expd, Int_.Mult(val, multiplier));}
@Test public void Base2Ary() {
@Test public void Base2Ary() {
tst_Base2Ary( 1, 256, 1);
tst_Base2Ary( 2, 256, 2);
tst_Base2Ary( 3, 256, 1, 2);
@ -50,7 +50,7 @@ public class Math__tst {
tst_Base2Ary( 6, 256, 2, 4);
tst_Base2Ary(511, 256, 1, 2, 4, 8, 16, 32, 64, 128, 256);
} void tst_Base2Ary(int v, int max, int... expd) {Tfds.Eq_ary(expd, Math_.Base2Ary(v, max));}
@Test public void Round() {
@Test public void Round() {
tst_Round(1.5 , 0, 2);
tst_Round(2.5 , 0, 3);
tst_Round(2.123 , 2, 2.12);

@ -1,29 +1,29 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;
public class Object__tst {
@Before public void init() {} private Object__fxt fxt = new Object__fxt();
@Test public void Eq() {
@Test public void Eq() {
fxt.Test_eq(null, null, true); // both null
fxt.Test_eq(5, 5, true); // both non-null
fxt.Test_eq(5, null, false); // rhs non-null
fxt.Test_eq(null, 5, false); // lhs non-null
}
@Test public void Xto_str_loose_or_null() {
@Test public void Xto_str_loose_or_null() {
fxt.Test_xto_str_loose_or_null(null, null);
fxt.Test_xto_str_loose_or_null(2449.6000000000004d, "2449.6");
}

@ -1,29 +1,29 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;
public class Ordered_hash_tst {
@Before public void setup() {
hash = Ordered_hash_.New();
}
@Test public void Get_at() {
@Test public void Get_at() {
hash.Add("key1", "val1");
Tfds.Eq("val1", hash.Get_at(0));
}
@Test public void iterator() {
@Test public void iterator() {
hash.Add("key2", "val2");
hash.Add("key1", "val1");
@ -33,5 +33,16 @@ public class Ordered_hash_tst {
Tfds.Eq("val2", list.Get_at(0));
Tfds.Eq("val1", list.Get_at(1));
}
// NOTE: this test shows that Del breaks iterator when vals are the same
// @Test
// public void Del() {
// hash.Add("a", "v1");
// hash.Add("b", "v2");
// hash.Add("c", "v1");
// hash.Del("c");
// Tfds.Eq("v1", hash.Get_at(0)); // should be "v1" b/c "a" was not deleted, but Del deletes "c" and first instance of "v1"
// }
Ordered_hash hash;
}

@ -1,21 +1,22 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import java.lang.*;
import gplx.core.strings.*; import gplx.langs.gfs.*; import gplx.core.envs.*;
import gplx.core.envs.Op_sys;
import gplx.core.strings.String_bldr;
import gplx.core.strings.String_bldr_;
public class String_ {
// -------- BASELIB_COPY --------
public static final Class<?> Cls_ref_type = String.class;
@ -145,11 +146,10 @@ public class String_ {
public static int FindFwd(String s, String find, int bgn, int end) {
int rv = FindFwd(s, find, bgn);
return rv > end ? String_.Find_none : rv;
}
public static int FindBwd(String s, String find) {return s.lastIndexOf(find);}
public static int FindBwd(String s, String find, int pos) {
return s.lastIndexOf(find, pos);
}
}
public static int FindBwdOr(String s, String find, int or) {int pos = FindBwd(s, find); return pos == Pos_neg1 ? or : pos;}
public static int FindBwd(String s, String find) {return s.lastIndexOf(find);}
public static int FindBwd(String s, String find, int pos) {return s.lastIndexOf(find, pos);}
public static int FindBetween(String s, String find, int bgn, int end) {
int rv = FindFwd(s, find, bgn);
return (rv > end) ? String_.Find_none : rv;

@ -1,22 +1,22 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
import org.junit.*;
public class String__tst {
@Test public void LimitToFirst() {
@Test public void LimitToFirst() {
tst_LimitToFirst("abc", 0, "");
tst_LimitToFirst("abc", 1, "a");
tst_LimitToFirst("abc", 2, "ab");
@ -26,7 +26,7 @@ public class String__tst {
}
void tst_LimitToFirst(String s, int v, String expd) {Tfds.Eq(expd, String_.LimitToFirst(s, v));}
void err_LimitToFirst(String s, int v) {try {String_.LimitToFirst(s, v);} catch (Exception exc) {Tfds.Err_classMatch(exc, Err.class); return;} Tfds.Fail_expdError();}
@Test public void LimitToLast() {
@Test public void LimitToLast() {
tst_LimitToLast("abc", 0, "");
tst_LimitToLast("abc", 1, "c");
tst_LimitToLast("abc", 2, "bc");
@ -36,7 +36,7 @@ public class String__tst {
}
void tst_LimitToLast(String s, int v, String expd) {Tfds.Eq(expd, String_.LimitToLast(s, v));}
void err_LimitToLast(String s, int v) {try {String_.LimitToLast(s, v);} catch (Exception exc) {Tfds.Err_classMatch(exc, Err.class); return;} Tfds.Fail_expdError();}
@Test public void DelBgn() {
@Test public void DelBgn() {
tst_DelBgn("abc", 0, "abc");
tst_DelBgn("abc", 1, "bc");
tst_DelBgn("abc", 2, "c");
@ -46,7 +46,7 @@ public class String__tst {
}
void tst_DelBgn(String s, int v, String expd) {Tfds.Eq(expd, String_.DelBgn(s, v));}
void err_DelBgn(String s, int v) {try {String_.DelBgn(s, v);} catch (Exception exc) {Tfds.Err_classMatch(exc, Err.class); return;} Tfds.Fail_expdError();}
@Test public void DelBgnIf() {
@Test public void DelBgnIf() {
tst_DelBgnIf("abc", "", "abc");
tst_DelBgnIf("abc", "a", "bc");
tst_DelBgnIf("abc", "ab", "c");
@ -58,7 +58,7 @@ public class String__tst {
}
void tst_DelBgnIf(String s, String v, String expd) {Tfds.Eq(expd, String_.DelBgnIf(s, v));}
void err_DelBgnIf(String s, String v) {try {String_.DelBgnIf(s, v);} catch (Exception exc) {Tfds.Err_classMatch(exc, Err.class); return;} Tfds.Fail_expdError();}
@Test public void DelEnd() {
@Test public void DelEnd() {
tst_DelEnd("abc", 0, "abc");
tst_DelEnd("abc", 1, "ab");
tst_DelEnd("abc", 2, "a");
@ -68,7 +68,7 @@ public class String__tst {
}
void tst_DelEnd(String s, int v, String expd) {Tfds.Eq(expd, String_.DelEnd(s, v));}
void err_DelEnd(String s, int v) {try {String_.DelEnd(s, v);} catch (Exception exc) {Tfds.Err_classMatch(exc, Err.class); return;} Tfds.Fail_expdError();}
@Test public void DelEndIf() {
@Test public void DelEndIf() {
tst_DelEndIf("abc", "", "abc");
tst_DelEndIf("abc", "c", "ab");
tst_DelEndIf("abc", "bc", "a");
@ -80,7 +80,7 @@ public class String__tst {
}
void tst_DelEndIf(String s, String v, String expd) {Tfds.Eq(expd, String_.DelEndIf(s, v));}
void err_DelEndIf(String s, String v) {try {String_.DelEndIf(s, v);} catch (Exception exc) {Tfds.Err_classMatch(exc, Err.class); return;} Tfds.Fail_expdError();}
@Test public void MidByPos() {
@Test public void MidByPos() {
tst_MidByPos("abc", 0, 0, "");
tst_MidByPos("abc", 0, 1, "a");
tst_MidByPos("abc", 0, 2, "ab");
@ -91,7 +91,7 @@ public class String__tst {
}
void tst_MidByPos(String s, int bgn, int end, String expd) {Tfds.Eq(expd, String_.Mid(s, bgn, end));}
void err_MidByPos(String s, int bgn, int end) {try {String_.Mid(s, bgn, end);} catch (Exception e) {Tfds.Err_classMatch(e, Err.class); return;} Tfds.Fail_expdError();}
@Test public void TrimEnd() {
@Test public void TrimEnd() {
tst_TrimEnd("a", "a");
tst_TrimEnd("a ", "a");
tst_TrimEnd("a\t", "a");
@ -103,19 +103,19 @@ public class String__tst {
}
void tst_TrimEnd(String s, String expd) {Tfds.Eq(expd, String_.TrimEnd(s));}
@Test public void Count() {
@Test public void Count() {
String text = "0 0 0";
Tfds.Eq(3, String_.Count(text, "0"));
}
@Test public void Has() {
@Test public void Has() {
String text = "find word";
Tfds.Eq_true(String_.Has(text, "word"));
Tfds.Eq_false(String_.Has(text, "nothing"));
}
@Test public void Repeat() {
@Test public void Repeat() {
Tfds.Eq("333", String_.Repeat("3", 3));
}
@Test public void Split() {
@Test public void Split() {
tst_Split("ab", " ", "ab"); // no match -> return array with original input
tst_Split("ab cd", " ", "ab", "cd"); // separator.length = 1
tst_Split("ab+!cd", "+!", "ab", "cd"); // separator.length = 2
@ -132,12 +132,12 @@ public class String__tst {
// acceptance
tst_Split("this\r\nis\na\rtest\r\n.", "\r\n", "this", "is\na\rtest", ".");
} void tst_Split(String text, String separator, String... expd) {Tfds.Eq_ary(expd, String_.Split(text, separator));}
@Test public void Concat_with_obj() {
@Test public void Concat_with_obj() {
tst_ConcatWith_any("a|b", "|", "a", "b"); // do not append final delimiter
tst_ConcatWith_any("a||c", "|", "a", null, "c"); // null
tst_ConcatWith_any("a|b", "|", Object_.Ary("a", "b")); // pass array as arg
} void tst_ConcatWith_any(String expd, String delimiter, Object... array) {Tfds.Eq(expd, String_.Concat_with_obj(delimiter, array));}
@Test public void Compare_byteAry() {
@Test public void Compare_byteAry() {
tst_Compare_byteAry("a", "a", CompareAble_.Same);
tst_Compare_byteAry("a", "b", CompareAble_.Less);
tst_Compare_byteAry("b", "a", CompareAble_.More);
@ -148,14 +148,14 @@ public class String__tst {
tst_Compare_byteAry("101", "1-0-1", CompareAble_.More); // NOTE: regular String_.Compare_as_ordinals returns Less in .NET, More in Java
tst_Compare_byteAry("1-0-1", "101 (album)", CompareAble_.Less);
} void tst_Compare_byteAry(String lhs, String rhs, int expd) {Tfds.Eq(expd, String_.Compare_byteAry(lhs, rhs));}
@Test public void FindBwd() { // WORKAROUND.CS:String.LastIndexOf returns -1 for multi-chars;
@Test public void FindBwd() { // WORKAROUND.CS:String.LastIndexOf returns -1 for multi-chars;
tst_FindRev("abc", "a", 0, 0);
tst_FindRev("abc", "ab", 0, 0); // 2 chars
tst_FindRev("abc", "abc", 0, 0); // 3 chars
tst_FindRev("ab", "abc", 0, -1); // out of index error
tst_FindRev("ababab", "ab", 2, 2); // make sure cs implementation doesn't pick up next
} void tst_FindRev(String s, String find, int pos, int expd) {Tfds.Eq(expd, String_.FindBwd(s, find, pos));}
@Test public void Extract_after_bwd() {
@Test public void Extract_after_bwd() {
Extract_after_bwd_tst("a/b", "/", "b");
Extract_after_bwd_tst("a/", "/", "");
Extract_after_bwd_tst("a", "/", "");

@ -1,38 +1,38 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.brys; import gplx.*; import gplx.core.*;
import org.junit.*;
public class Bry_bfr_mkr_tst {
private final Bry_bfr_mkr_fxt fxt = new Bry_bfr_mkr_fxt();
@Before public void setup() {fxt.Clear();}
@Test public void Get_1() {fxt.Clear().Get().Test__used(0);}
@Test public void Get_2() {fxt.Clear().Get().Get().Test__used(0, 1);}
@Test public void Get_3() {fxt.Clear().Get().Get().Get().Test__used(0, 1, 2);}
@Test public void Rls() {fxt.Clear().Get().Rls(0).Test__used();}
@Test public void Rls_skip_1() {
@Test public void Get_1() {fxt.Clear().Get().Test__used(0);}
@Test public void Get_2() {fxt.Clear().Get().Get().Test__used(0, 1);}
@Test public void Get_3() {fxt.Clear().Get().Get().Get().Test__used(0, 1, 2);}
@Test public void Rls() {fxt.Clear().Get().Rls(0).Test__used();}
@Test public void Rls_skip_1() {
fxt.Clear().Get().Get().Rls(0).Test__used(-1, 1);
fxt.Get().Test__used(0, 1);
}
@Test public void Rls_skip_2_1() {
@Test public void Rls_skip_2_1() {
fxt.Clear().Get().Get().Get().Rls(1).Rls(0).Test__used(-1, -1, 2);
fxt.Get().Test__used(0, -1, 2);
fxt.Get().Test__used(0, 1, 2);
fxt.Get().Test__used(0, 1, 2, 3);
}
@Test public void Get_rls_get() { // PURPOSE: defect in which last rls failed b/c was not doing ++ if rv existed
@Test public void Get_rls_get() { // PURPOSE: defect in which last rls failed b/c was not doing ++ if rv existed
fxt.Clear().Get().Rls(0).Get().Get().Rls(1).Rls(0).Test__used();
}
}

@ -1,20 +1,28 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.brys; import gplx.*; import gplx.core.*;
import gplx.core.errs.*; import gplx.core.btries.*;
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.brys; import gplx.Bool_;
import gplx.Bry_;
import gplx.Bry_find_;
import gplx.Byte_;
import gplx.Byte_ascii;
import gplx.Double_;
import gplx.Int_;
import gplx.String_;
import gplx.core.btries.Btrie_rv;
import gplx.core.btries.Btrie_slim_mgr;
public class Bry_rdr {
private final gplx.core.primitives.Int_obj_ref pos_ref = gplx.core.primitives.Int_obj_ref.New_neg1();
private final Btrie_rv trv = new Btrie_rv();
@ -22,6 +30,9 @@ public class Bry_rdr {
public int Src_end() {return src_end;} protected int src_end;
public int Pos() {return pos;} protected int pos;
public boolean Pos_is_eos() {return pos == src_end;}
public boolean Pos_is_reading() {return pos > -1 && pos < src_end;}
public byte Cur() {return src[pos];}
public byte Nxt() {return pos + 1 >= src_end ? Not_found : src[pos + 1];}
public Bry_rdr Dflt_dlm_(byte b) {this.dflt_dlm = b; return this;} private byte dflt_dlm;
public Bry_rdr Fail_throws_err_(boolean v) {err_wkr.Fail_throws_err_(v); return this;}
public Bry_rdr Init_by_src(byte[] src) {err_wkr.Init_by_page("", src); this.pos = 0; this.src = src; this.src_end = src.length; return this;}
@ -35,13 +46,19 @@ public class Bry_rdr {
}
public Bry_err_wkr Err_wkr() {return err_wkr;} private Bry_err_wkr err_wkr = new Bry_err_wkr();
public int Move_to(int v) {this.pos = v; return pos;}
public int Move_to_last() {this.pos = src_end - 1; return pos;}
public int Move_to_end() {this.pos = src_end; return pos;}
public int Move_by_one() {return Move_by(1);}
public int Move_by(int v) {this.pos += v; return pos;}
public int Find_fwd_lr() {return Find_fwd(dflt_dlm , Bool_.Y, Bool_.N, Fail_if_missing);}
public int Find_fwd_lr(byte find) {return Find_fwd(find , Bool_.Y, Bool_.N, Fail_if_missing);}
public int Find_fwd_lr_or(byte find, int or)
{return Find_fwd(find , Bool_.Y, Bool_.N, or);}
public int Find_fwd_lr(String find) {return Find_fwd(Bry_.new_u8(find), Bool_.Y, Bool_.N, Fail_if_missing);}
public int Find_fwd_lr(byte[] find) {return Find_fwd(find , Bool_.Y, Bool_.N, Fail_if_missing);}
public int Find_fwd_lr_or(String find, int or) {return Find_fwd(Bry_.new_u8(find), Bool_.Y, Bool_.N, or);}
public int Find_fwd_lr_or(byte[] find, int or)
{return Find_fwd(find , Bool_.Y, Bool_.N, or);}
public int Find_fwd_rr() {return Find_fwd(dflt_dlm , Bool_.N, Bool_.N, Fail_if_missing);}
public int Find_fwd_rr(byte find) {return Find_fwd(find , Bool_.N, Bool_.N, Fail_if_missing);}
public int Find_fwd_rr(byte[] find) {return Find_fwd(find , Bool_.N, Bool_.N, Fail_if_missing);}
@ -141,6 +158,29 @@ public class Bry_rdr {
int bgn = pos;
return Bry_.Mid(src, bgn, Find_fwd_lr(b));
}
public int Move_fwd_while(byte b) {
while (pos < src_end) {
if (src[pos] != b) {
break;
}
pos++;
}
return pos;
}
public int Move_bwd_while(byte b) {
while (pos > -1) {
if (src[pos] != b) {
return pos + 1; // return position which is start of b sequence
}
pos--;
}
return -1;
}
public boolean Match(byte[] find) { // same as Is but no auto-move
int find_len = find.length;
int find_end = pos + find_len;
return Bry_.Match(src, pos, find_end, find, 0, find_len);
}
public boolean Is(byte find) {
boolean rv = src[pos] == find;
if (rv) ++pos; // only advance if match;
@ -189,7 +229,7 @@ public class Bry_rdr {
pos = trv.Pos();
return ((gplx.core.primitives.Byte_obj_val)rv_obj).Val();
}
@gplx.Virtual public Bry_rdr Skip_ws() {
public Bry_rdr Skip_ws() {
while (pos < src_end) {
switch (src[pos]) {
case Byte_ascii.Tab: case Byte_ascii.Nl: case Byte_ascii.Cr: case Byte_ascii.Space:
@ -226,4 +266,5 @@ public class Bry_rdr {
return this;
}
private static final int Fail_if_missing = Int_.Min_value;
public static final int Not_found = Bry_find_.Not_found;
}

@ -1,35 +1,35 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.brys; import gplx.*; import gplx.core.*;
import org.junit.*;
public class Bry_rdr_tst {
@Before public void init() {fxt.Clear();} private Bry_rdr_fxt fxt = new Bry_rdr_fxt();
@Test public void Int() {
@Test public void Int() {
fxt.Init_src("12|3456|789");
fxt.Test_read_int(12);
fxt.Test_read_int(3456);
fxt.Test_read_int(789);
fxt.Test_read_int(Int_.Min_value);
}
@Test public void Int_negative() {
@Test public void Int_negative() {
fxt.Init_src("-1|-2");
fxt.Test_read_int(-1);
fxt.Test_read_int(-2);
}
@Test public void Bry() {
@Test public void Bry() {
fxt.Init_src("abc|d||ef");
fxt.Test_read_bry("abc");
fxt.Test_read_bry("d");

@ -1,22 +1,22 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.brys.args; import gplx.*; import gplx.core.*; import gplx.core.brys.*;
import org.junit.*;
public class Bfr_arg__time_tst {
@Test public void Basic() {
@Test public void Basic() {
Time_fmtr_arg_fxt fxt = new Time_fmtr_arg_fxt().Clear();
fxt.XferAry( 1, "01s"); // seconds
fxt.XferAry( 62, "01m 02s"); // minutes

@ -1,48 +1,48 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.brys.fmtrs; import gplx.*; import gplx.core.*; import gplx.core.brys.*;
import org.junit.*;
public class Bry_fmtr_tst {
private final Bry_fmtr_fxt fxt = new Bry_fmtr_fxt();
@Test public void Text() {fxt.Clear().Fmt("a").Test("a");}
@Test public void Idx__1() {fxt.Clear().Fmt("~{0}").Args("a").Test("a");}
@Test public void Idx__3() {fxt.Clear().Fmt("~{0}~{1}~{2}").Args("a", "b", "c").Test("abc");}
@Test public void Idx__mix() {fxt.Clear().Fmt("a~{0}c~{1}e").Args("b", "d").Test("abcde");}
@Test public void Idx__missing() {fxt.Clear().Fmt("~{0}").Test("~{0}");}
@Test public void Text() {fxt.Clear().Fmt("a").Test("a");}
@Test public void Idx__1() {fxt.Clear().Fmt("~{0}").Args("a").Test("a");}
@Test public void Idx__3() {fxt.Clear().Fmt("~{0}~{1}~{2}").Args("a", "b", "c").Test("abc");}
@Test public void Idx__mix() {fxt.Clear().Fmt("a~{0}c~{1}e").Args("b", "d").Test("abcde");}
@Test public void Idx__missing() {fxt.Clear().Fmt("~{0}").Test("~{0}");}
@Test public void Key__basic() {fxt.Clear().Fmt("~{key}").Keys("key").Args("a").Test("a");}
@Test public void Key__mult() {fxt.Clear().Fmt("~{key1}~{key2}").Keys("key1", "key2").Args("a", "b").Test("ab");}
@Test public void Key__repeat() {fxt.Clear().Fmt("~{key1}~{key1}").Keys("key1").Args("a").Test("aa");}
@Test public void Key__basic() {fxt.Clear().Fmt("~{key}").Keys("key").Args("a").Test("a");}
@Test public void Key__mult() {fxt.Clear().Fmt("~{key1}~{key2}").Keys("key1", "key2").Args("a", "b").Test("ab");}
@Test public void Key__repeat() {fxt.Clear().Fmt("~{key1}~{key1}").Keys("key1").Args("a").Test("aa");}
@Test public void Mix() {fxt.Clear().Fmt("~{key1}~{1}").Keys("key1", "key2").Args("a", "b").Test("ab");}
@Test public void Mix() {fxt.Clear().Fmt("~{key1}~{1}").Keys("key1", "key2").Args("a", "b").Test("ab");}
@Test public void Simple() {
@Test public void Simple() {
fxt.Clear().Fmt("0~{key1}1~{key2}2").Keys("key1", "key2").Args(".", ",").Test("0.1,2");
}
@Test public void Cmd() {
@Test public void Cmd() {
Bry_fmtr_tst_mok mok = new Bry_fmtr_tst_mok();
Bry_fmtr fmtr = Bry_fmtr.new_("0~{key1}2~{<>3<>}4", "key1").Eval_mgr_(mok);
Tfds.Eq("012~{<>3<>}4", fmtr.Bld_str_many("1"));
mok.Enabled_(true);
Tfds.Eq("01234", fmtr.Bld_str_many("1"));
}
@Test public void Bld_bfr_many_and_set_fmt() {
@Test public void Bld_bfr_many_and_set_fmt() {
fxt.Bld_bfr_many_and_set_fmt("a~{0}c", Object_.Ary("b"), "abc");
}
@Test public void Escape_tilde() {
@Test public void Escape_tilde() {
Tfds.Eq("~~~~~~", Bry_fmtr.Escape_tilde("~~~"));
}
}

@ -1,31 +1,31 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.brys.fmts; import gplx.*; import gplx.core.*; import gplx.core.brys.*;
import org.junit.*;
public class Bry_fmt_tst {
private final Bry_fmt_fxt fxt = new Bry_fmt_fxt();
@Test public void Text() {fxt.Clear().Fmt("a").Test("a");}
@Test public void Key__basic() {fxt.Clear().Fmt("~{key}").Vals("a").Test("a");}
@Test public void Key__mult() {fxt.Clear().Fmt("~{key1}~{key2}").Vals("a", "b").Test("ab");}
@Test public void Key__repeat() {fxt.Clear().Fmt("~{key1}~{key1}").Vals("a").Test("aa");}
@Test public void Key__missing() {fxt.Clear().Fmt("~{key}").Test("~{key}");}
@Test public void Tilde() {fxt.Clear().Fmt("~~~~").Test("~~");}
@Test public void Simple() {fxt.Clear().Fmt("0~{key1}1~{key2}2").Vals(".", ",").Test("0.1,2");}
@Test public void Arg() {fxt.Clear().Fmt("~{custom}").Args("custom", new Bfr_fmt_arg_mok(123)).Test("123");}
@Test public void Keys() {fxt.Clear().Fmt("~{b}~{c}~{a}").Keys("a", "b", "c").Vals("a", "b", "c").Test("bca");}
@Test public void Text() {fxt.Clear().Fmt("a").Test("a");}
@Test public void Key__basic() {fxt.Clear().Fmt("~{key}").Vals("a").Test("a");}
@Test public void Key__mult() {fxt.Clear().Fmt("~{key1}~{key2}").Vals("a", "b").Test("ab");}
@Test public void Key__repeat() {fxt.Clear().Fmt("~{key1}~{key1}").Vals("a").Test("aa");}
@Test public void Key__missing() {fxt.Clear().Fmt("~{key}").Test("~{key}");}
@Test public void Tilde() {fxt.Clear().Fmt("~~~~").Test("~~");}
@Test public void Simple() {fxt.Clear().Fmt("0~{key1}1~{key2}2").Vals(".", ",").Test("0.1,2");}
@Test public void Arg() {fxt.Clear().Fmt("~{custom}").Args("custom", new Bfr_fmt_arg_mok(123)).Test("123");}
@Test public void Keys() {fxt.Clear().Fmt("~{b}~{c}~{a}").Keys("a", "b", "c").Vals("a", "b", "c").Test("bca");}
}
class Bfr_fmt_arg_mok implements Bfr_arg {
private int num;

@ -13,18 +13,18 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.brys.fmts; import gplx.*; import gplx.core.*; import gplx.core.brys.*;
import org.junit.*;
public class Bry_keys_parser_tst {
private final Bry_keys_parser_fxt fxt = new Bry_keys_parser_fxt();
@Test public void None() {fxt.Test("a");}
@Test public void One() {fxt.Test("~{a}" , "a");}
@Test public void Many() {fxt.Test("~{a}b~{c}d~{e}" , "a", "c", "e");}
@Test public void Dupe() {fxt.Test("~{a}b~{a}" , "a");}
@Test public void Bug__space() {fxt.Test("~{a}~{b} ~{c}" , "a", "b", "c");} // DATE:2016-08-02
}
class Bry_keys_parser_fxt {
public void Test(String fmt, String... expd) {
Tfds.Eq_ary(expd, String_.Ary(Bry_fmt_parser_.Parse_keys(Bry_.new_u8(fmt))));
}
}
package gplx.core.brys.fmts; import gplx.*; import gplx.core.*; import gplx.core.brys.*;
import org.junit.*;
public class Bry_keys_parser_tst {
private final Bry_keys_parser_fxt fxt = new Bry_keys_parser_fxt();
@Test public void None() {fxt.Test("a");}
@Test public void One() {fxt.Test("~{a}" , "a");}
@Test public void Many() {fxt.Test("~{a}b~{c}d~{e}" , "a", "c", "e");}
@Test public void Dupe() {fxt.Test("~{a}b~{a}" , "a");}
@Test public void Bug__space() {fxt.Test("~{a}~{b} ~{c}" , "a", "b", "c");} // DATE:2016-08-02
}
class Bry_keys_parser_fxt {
public void Test(String fmt, String... expd) {
Tfds.Eq_ary(expd, String_.Ary(Bry_fmt_parser_.Parse_keys(Bry_.new_u8(fmt))));
}
}

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.btries; import gplx.*; import gplx.core.*;
import org.junit.*;
public class Btrie_bwd_mgr_tst {
@ -22,7 +22,7 @@ public class Btrie_bwd_mgr_tst {
run_Add("c" , 1);
run_Add("abc" , 123);
}
@Test public void Get_by() {
@Test public void Get_by() {
ini_setup1();
tst_MatchAtCur("c" , 1);
tst_MatchAtCur("abc" , 123);
@ -30,17 +30,17 @@ public class Btrie_bwd_mgr_tst {
tst_MatchAtCur("yzabc" , 123);
tst_MatchAtCur("ab" , null);
}
@Test public void Fetch_intl() {
@Test public void Fetch_intl() {
trie = new Btrie_bwd_mgr(false);
run_Add("a<>", 1);
tst_MatchAtCur("a<>" , 1);
tst_MatchAtCur("<22>" , null);
}
@Test public void Eos() {
@Test public void Eos() {
ini_setup1();
tst_Match("ab", Byte_ascii.Ltr_c, 2, 123);
}
@Test public void Match_exact() {
@Test public void Match_exact() {
ini_setup1();
tst_MatchAtCurExact("c", 1);
tst_MatchAtCurExact("bc", null);
@ -51,7 +51,7 @@ public class Btrie_bwd_mgr_tst {
run_Add("a" , 1);
run_Add("b" , 2);
}
@Test public void Match_2() {
@Test public void Match_2() {
ini_setup2();
tst_MatchAtCur("a", 1);
tst_MatchAtCur("b", 2);
@ -61,7 +61,7 @@ public class Btrie_bwd_mgr_tst {
run_Add("a" , 1);
run_Add("b" , 2);
}
@Test public void CaseAny() {
@Test public void CaseAny() {
ini_setup_caseAny();
tst_MatchAtCur("a", 1);
tst_MatchAtCur("A", 1);

@ -1,54 +1,54 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.btries; import gplx.*; import gplx.core.*;
import org.junit.*;
public class Btrie_fast_mgr_tst {
private Btrie_fast_mgr_fxt fxt = new Btrie_fast_mgr_fxt();
@Before public void init() {fxt.Clear();}
@Test public void Get_by() {
@Test public void Get_by() {
fxt.Test_matchAtCur("a" , 1);
fxt.Test_matchAtCur("abc" , 123);
fxt.Test_matchAtCur("ab" , 1);
fxt.Test_matchAtCur("abcde" , 123);
fxt.Test_matchAtCur(" a" , null);
}
@Test public void Bos() {
@Test public void Bos() {
fxt.Test_match("bc", Byte_ascii.Ltr_a, -1, 123);
}
@Test public void Match_exact() {
@Test public void Match_exact() {
fxt.Test_matchAtCurExact("a", 1);
fxt.Test_matchAtCurExact("ab", null);
fxt.Test_matchAtCurExact("abc", 123);
}
@Test public void Del_noop__no_match() {
@Test public void Del_noop__no_match() {
fxt.Exec_del("d");
fxt.Test_matchAtCurExact("a" , 1);
fxt.Test_matchAtCurExact("abc" , 123);
}
@Test public void Del_noop__partial_match() {
@Test public void Del_noop__partial_match() {
fxt.Exec_del("ab");
fxt.Test_matchAtCurExact("a" , 1);
fxt.Test_matchAtCurExact("abc" , 123);
}
@Test public void Del_match__long() {
@Test public void Del_match__long() {
fxt.Exec_del("abc");
fxt.Test_matchAtCurExact("a" , 1);
fxt.Test_matchAtCurExact("abc" , null);
}
@Test public void Del_match__short() {
@Test public void Del_match__short() {
fxt.Exec_del("a");
fxt.Test_matchAtCurExact("a" , null);
fxt.Test_matchAtCurExact("abc" , 123);

@ -1,35 +1,35 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.btries; import gplx.*; import gplx.core.*;
import org.junit.*;
public class Btrie_slim_itm_tst {
private Btrie_slim_itm itm = new Btrie_slim_itm(Byte_.Zero, null, false);
@Before public void init() {itm.Clear();}
@Test public void Find_nil() {
@Test public void Find_nil() {
tst_Find(Byte_ascii.Ltr_a, null);
}
@Test public void Add_one() {
@Test public void Add_one() {
run_Add(Byte_ascii.Ltr_a);
tst_Find(Byte_ascii.Ltr_a, "a");
}
@Test public void Add_many() {
@Test public void Add_many() {
run_Add(Byte_ascii.Bang, Byte_ascii.Num_0, Byte_ascii.Ltr_a, Byte_ascii.Ltr_B);
tst_Find(Byte_ascii.Ltr_a, "a");
}
@Test public void Del() {
@Test public void Del() {
run_Add(Byte_ascii.Bang, Byte_ascii.Num_0, Byte_ascii.Ltr_a, Byte_ascii.Ltr_B);
tst_Find(Byte_ascii.Ltr_a, "a");
run_Del(Byte_ascii.Ltr_a);

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.btries; import gplx.*; import gplx.core.*;
import org.junit.*; import gplx.core.tests.*;
public class Btrie_slim_mgr_tst {
@ -23,7 +23,7 @@ public class Btrie_slim_mgr_tst {
run_Add("a" , 1);
run_Add("abc" , 123);
}
@Test public void Get_by() {
@Test public void Get_by() {
ini_setup1();
tst_MatchAtCur("a" , 1);
tst_MatchAtCur("abc" , 123);
@ -31,11 +31,11 @@ public class Btrie_slim_mgr_tst {
tst_MatchAtCur("abcde" , 123);
tst_MatchAtCur(" a" , null);
}
@Test public void Bos() {
@Test public void Bos() {
ini_setup1();
tst_Match("bc", Byte_ascii.Ltr_a, -1, 123);
}
@Test public void Match_exact() {
@Test public void Match_exact() {
ini_setup1();
tst_MatchAtCurExact("a", 1);
tst_MatchAtCurExact("ab", null);
@ -46,7 +46,7 @@ public class Btrie_slim_mgr_tst {
run_Add("a" , 1);
run_Add("b" , 2);
}
@Test public void Match_2() {
@Test public void Match_2() {
ini_setup2();
tst_MatchAtCur("a", 1);
tst_MatchAtCur("b", 2);
@ -56,12 +56,12 @@ public class Btrie_slim_mgr_tst {
run_Add("a" , 1);
run_Add("b" , 2);
}
@Test public void CaseAny() {
@Test public void CaseAny() {
ini_setup_caseAny();
tst_MatchAtCur("a", 1);
tst_MatchAtCur("A", 1);
}
@Test public void Del() {
@Test public void Del() {
ini_setup1();
trie.Del(Bry_.new_a7("a")); // delete "a"; "abc" still remains;
tst_MatchAtCur("a" , null);
@ -70,7 +70,7 @@ public class Btrie_slim_mgr_tst {
trie.Del(Bry_.new_a7("abc"));
tst_MatchAtCur("abc" , null);
}
@Test public void Match_none() {
@Test public void Match_none() {
Btrie_slim_mgr_fxt fxt = new Btrie_slim_mgr_fxt();
fxt.Init__add("k1", "v1");
fxt.Exec__match("ak1", 1, 3, "v1", 3); // 3 to position after match

@ -1,40 +1,40 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.caches; import gplx.*; import gplx.core.*;
import org.junit.*; import gplx.core.tests.*;
public class Lru_cache_tst {
private final Lru_cache_fxt fxt = new Lru_cache_fxt();
@Test public void Get_one() {
@Test public void Get_one() {
fxt.Exec__set("a", 5);
fxt.Test__get_y("a");
}
@Test public void Pop_one() {
@Test public void Pop_one() {
fxt.Exec__set("a", 10);
fxt.Exec__set("b", 10);
fxt.Test__get_n("a");
fxt.Test__get_y("b");
}
@Test public void Add_many() {
@Test public void Add_many() {
fxt.Exec__set("a", 4);
fxt.Exec__set("b", 3);
fxt.Exec__set("c", 2);
fxt.Exec__set("d", 1);
fxt.Test__get_y("a", "b", "c", "d");
}
@Test public void Pop_many() {
@Test public void Pop_many() {
fxt.Exec__set("a", 4);
fxt.Exec__set("b", 3);
fxt.Exec__set("c", 2);
@ -43,13 +43,13 @@ public class Lru_cache_tst {
fxt.Test__get_y("c", "d", "e");
fxt.Test__get_n("a", "b");
}
@Test public void Set_repeatedly() {
@Test public void Set_repeatedly() {
fxt.Exec__set("a", "a1", 10);
fxt.Exec__set("a", "a2", 10);
fxt.Exec__set("a", "a3", 10);
fxt.Test__get_val("a", "a3");
}
@Test public void Set_bumps_priority() {
@Test public void Set_bumps_priority() {
fxt.Exec__set("a", 2);
fxt.Exec__set("b", 3);
fxt.Exec__set("c", 2);
@ -58,14 +58,14 @@ public class Lru_cache_tst {
fxt.Test__get_y("a", "d");
fxt.Test__get_n("b", "c");
}
@Test public void Del() {
@Test public void Del() {
fxt.Exec__set("a", 2);
fxt.Exec__set("b", 2);
fxt.Exec__del("b");
fxt.Test__get_y("a");
fxt.Test__get_n("b");
}
@Test public void Clear() {
@Test public void Clear() {
fxt.Exec__set("a", 2);
fxt.Exec__set("b", 2);
fxt.Exec__clear();

@ -1,40 +1,40 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.criterias; import gplx.*; import gplx.core.*;
import org.junit.*;
import gplx.core.ios.*;
public class Criteria_ioItm_tst {
IoItmFil fil; Criteria crt; IoItm_fxt fx = IoItm_fxt.new_();
@Test public void IoType() {
@Test public void IoType() {
crt = crt_(IoItm_base_.Prop_Type, Criteria_.eq_(IoItmFil.Type_Fil));
tst_Match(true, crt, fx.fil_wnt_("C:\\fil.txt"));
tst_Match(false, crt, fx.dir_wnt_("C:\\dir"));
}
@Test public void Ext() {
@Test public void Ext() {
crt = crt_(IoItm_base_.Prop_Ext, Criteria_.eq_(".txt"));
tst_Match(true, crt, fx.fil_wnt_("C:\\fil.txt"));
tst_Match(false, crt, fx.fil_wnt_("C:\\fil.xml"), fx.fil_wnt_("C:\\fil.txt1"), fx.fil_wnt_("C:\\fil1.txt.xml"), fx.dir_wnt_("C:\\.txt"));
}
@Test public void Modified() {
@Test public void Modified() {
fil = fx.fil_wnt_("C:\\fil.txt");
crt = crt_(IoItmFil_.Prop_Modified, Criteria_.mte_(DateAdp_.parse_gplx("2001-01-01")));
tst_Match(true, crt, fil.ModifiedTime_(DateAdp_.parse_gplx("2001-01-02")), fil.ModifiedTime_(DateAdp_.parse_gplx("2001-01-01")));
tst_Match(false, crt, fil.ModifiedTime_(DateAdp_.parse_gplx("2000-12-31")));
}
@Test public void IoMatch() {
@Test public void IoMatch() {
Criteria crt = Criteria_ioMatch.parse(true, "*.txt", false);
CriteriaFxt fx_crt = new CriteriaFxt();
fx_crt.tst_Matches(crt, Io_url_.new_any_("file.txt"));

@ -1,22 +1,22 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.criterias; import gplx.*; import gplx.core.*;
import org.junit.*;
public class Criteria_tst {
@Test public void Equal() {
@Test public void Equal() {
Criteria crt = Criteria_.eq_(true);
fx.tst_Matches(crt, true);
fx.tst_MatchesNot(crt, false);
@ -26,7 +26,7 @@ public class Criteria_tst {
fx.tst_Matches(Criteria_.eq_("equal"), "equal");
fx.tst_Matches(Criteria_.eq_(date), date);
}
@Test public void Not() {
@Test public void Not() {
Criteria crt = Criteria_.eqn_(true);
fx.tst_Matches(crt, false);
fx.tst_MatchesNot(crt, true);
@ -36,7 +36,7 @@ public class Criteria_tst {
fx.tst_Matches(Criteria_.eqn_("equal"), "not equal");
fx.tst_Matches(Criteria_.eqn_(date), date.Add_minute(1));
}
@Test public void MoreThan() {
@Test public void MoreThan() {
Criteria crt = Criteria_.mt_(0);
fx.tst_Matches(crt, 1, 2);
fx.tst_MatchesNot(crt, 0, -1);
@ -47,21 +47,21 @@ public class Criteria_tst {
fx.tst_Matches(Criteria_.mt_(date), date.Add_minute(1));
fx.tst_Matches(Criteria_.mt_(false), true); // MISC: thus truth is greater than falsehood
}
@Test public void MoreThanEq() {
@Test public void MoreThanEq() {
Criteria crt = Criteria_.mte_(0);
fx.tst_Matches(crt, 0);
}
@Test public void Less() {
@Test public void Less() {
Criteria crt = Criteria_.lt_(0);
fx.tst_Matches(crt, -1, -2);
fx.tst_MatchesNot(crt, 0, 1);
fx.tst_MatchesFail(crt, "-1");
}
@Test public void LessEq() {
@Test public void LessEq() {
Criteria crt = Criteria_.lte_(0);
fx.tst_Matches(crt, 0);
}
@Test public void Between() {
@Test public void Between() {
Criteria crt = Criteria_.between_(-1, 1);
fx.tst_Matches(crt, 0, 1, -1);
fx.tst_MatchesNot(crt, -2, 2);
@ -70,7 +70,7 @@ public class Criteria_tst {
fx.tst_Matches(Criteria_.between_(1, -1), 0); // reverse range
fx.tst_Matches(Criteria_.between_("a", "c"), "b");
}
@Test public void In() {
@Test public void In() {
Criteria crt = Criteria_.in_(0, 1, 2);
fx.tst_Matches(crt, 0, 1, 2);
fx.tst_MatchesNot(crt, 3, -1);

@ -13,17 +13,17 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.encoders; import gplx.*; import gplx.core.*;
import org.junit.*;
public class B85_fp__tst {
private final B85_fp__fxt fxt = new B85_fp__fxt();
@Test public void Double_to_str() {
fxt.Test__to_str(.1d, "/\"");
}
}
class B85_fp__fxt {
public void Test__to_str(double val, String expd) {
byte[] actl = B85_fp_.To_bry(val);
Tfds.Eq_str(expd, String_.new_a7(actl));
}
}
package gplx.core.encoders; import gplx.*; import gplx.core.*;
import org.junit.*;
public class B85_fp__tst {
private final B85_fp__fxt fxt = new B85_fp__fxt();
@Test public void Double_to_str() {
fxt.Test__to_str(.1d, "/\"");
}
}
class B85_fp__fxt {
public void Test__to_str(double val, String expd) {
byte[] actl = B85_fp_.To_bry(val);
Tfds.Eq_str(expd, String_.new_a7(actl));
}
}

@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.encoders; import gplx.*; import gplx.core.*;
import org.junit.*;
public class Base85__tst {
private final Base85__fxt fxt = new Base85__fxt();
@Test public void Log() {
@Test public void Log() {
fxt.Test_log( 0, 1);
fxt.Test_log( 84, 1);
fxt.Test_log( 85, 2);
@ -29,7 +29,7 @@ public class Base85__tst {
fxt.Test_log( 52200625, 5);
fxt.Test_log(Int_.Max_value, 5);
}
@Test public void To_str() {
@Test public void To_str() {
fxt.Test_to_str( 0, "!");
fxt.Test_to_str( 84, "u");
fxt.Test_to_str( 85, "\"!");
@ -40,7 +40,7 @@ public class Base85__tst {
fxt.Test_to_str( 52200624, "uuuu");
fxt.Test_to_str( 52200625, "\"!!!!");
}
@Test public void XtoStrAry() {
@Test public void XtoStrAry() {
byte[] ary = new byte[9];
fxt.Exec_to_str(ary, 0, 2); // !!#
fxt.Exec_to_str(ary, 3, 173); // !#$

@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.encoders; import gplx.*; import gplx.core.*;
import org.junit.*; import gplx.core.tests.*;
public class Hex_utl__tst {
private final Hex_utl__fxt fxt = new Hex_utl__fxt();
@Test public void To_int() {
@Test public void To_int() {
fxt.Test__to_int("0" , 0);
fxt.Test__to_int("F" , 15);
fxt.Test__to_int("0F" , 15);
@ -29,7 +29,7 @@ public class Hex_utl__tst {
fxt.Test__to_int("7FFFFFFF" , Int_.Max_value);
fxt.Test__to_int_bry("100" , 256);
}
@Test public void To_str() {
@Test public void To_str() {
fxt.Test__to_str(0 , "0");
fxt.Test__to_str(15 , "F");
fxt.Test__to_str(16 , "10");
@ -40,11 +40,11 @@ public class Hex_utl__tst {
fxt.Test__to_str(15, 2 , "0F");
fxt.Test__to_str(15, 3 , "00F");
}
@Test public void Write() {
@Test public void Write() {
fxt.Test__write("[00000000]", 1, 9, 15, "[0000000F]");
fxt.Test__write("[00000000]", 1, 9, 255, "[000000FF]");
}
@Test public void Write_bfr() {
@Test public void Write_bfr() {
fxt.Test__write_bfr(Bool_.Y, 0, "0");
fxt.Test__write_bfr(Bool_.Y, 15, "f");
fxt.Test__write_bfr(Bool_.Y, 16, "10");
@ -53,7 +53,7 @@ public class Hex_utl__tst {
fxt.Test__write_bfr(Bool_.Y, 256, "100");
fxt.Test__write_bfr(Bool_.Y, Int_.Max_value, "7fffffff");
}
@Test public void Encode() {
@Test public void Encode() {
fxt.Test__parse_hex_to_bry("E2A7BC", 226, 167, 188);
}
}

@ -1,6 +1,6 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
Copyright (C) 2012-2021 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
@ -13,34 +13,44 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.envs; import gplx.*; import gplx.core.*;
public class Env_ {
public static void Init(String[] args, String appNameAndExt, Class<?> type) {
mode_testing = false;
mode_debug = String_.In("GPLX_DEBUG_MODE_ENABLED", args);
appArgs = args;
appUrl = Jar_adp_.Url_type(type).OwnerDir().GenSubFil(appNameAndExt);
}
public static void Init_swt(String[] args, Class<?> type) { // DATE:2014-06-23
mode_testing = false;
mode_debug = String_.In("GPLX_DEBUG_MODE_ENABLED", args);
appArgs = args;
appUrl = Jar_adp_.Url_type(type);
}
public static void Init_drd() {
mode_testing = mode_debug = false;
}
public static void Init_testing() {mode_testing = true;}
public static void Init_testing_n_() {mode_testing = false;}
public static boolean Mode_testing() {return mode_testing;} private static boolean mode_testing = true;
public static boolean Mode_debug() {return mode_debug;} private static boolean mode_debug = false;
public static String[] AppArgs() {return appArgs;} static String[] appArgs;
public static Io_url AppUrl() {
if (mode_testing) return Io_url_.mem_fil_("mem/testing.jar");
if (appUrl == Io_url_.Empty) throw Err_.new_wo_type("Env_.Init was not called");
return appUrl;
} static Io_url appUrl = Io_url_.Empty;
public static final String LocalHost = "127.0.0.1";
public static String NewLine_lang() {return mode_testing ? "\n" : "\n";}
}
package gplx.core.envs;
import gplx.Err_;
import gplx.Io_url;
import gplx.Io_url_;
import gplx.String_;
public class Env_ {
public static void Init(String[] args, String appNameAndExt, Class<?> type) {
mode_testing = false;
mode_debug = String_.In("GPLX_DEBUG_MODE_ENABLED", args);
appArgs = args;
appUrl = Jar_adp_.Url_type(type).OwnerDir().GenSubFil(appNameAndExt);
}
public static void Init_swt(String[] args, Class<?> type) { // DATE:2014-06-23
mode_testing = false;
mode_debug = String_.In("GPLX_DEBUG_MODE_ENABLED", args);
appArgs = args;
appUrl = Jar_adp_.Url_type(type);
}
public static void Init_cmd(String[] args, Io_url url) {
mode_testing = false;
mode_debug = String_.In("GPLX_DEBUG_MODE_ENABLED", args);
appArgs = args;
appUrl = url;
}
public static void Init_drd() {
mode_testing = mode_debug = false;
}
public static void Init_testing() {mode_testing = true;}
public static void Init_testing_n_() {mode_testing = false;}
public static boolean Mode_testing() {return mode_testing;} private static boolean mode_testing = true;
public static boolean Mode_debug() {return mode_debug;} private static boolean mode_debug = false;
public static String[] AppArgs() {return appArgs;} static String[] appArgs;
public static Io_url AppUrl() {
if (mode_testing) return Io_url_.mem_fil_("mem/testing.jar");
if (appUrl == Io_url_.Empty) throw Err_.new_wo_type("Env_.Init was not called");
return appUrl;
} static Io_url appUrl = Io_url_.Empty;
public static final String LocalHost = "127.0.0.1";
public static String NewLine_lang() {return mode_testing ? "\n" : "\n";}
}

@ -13,18 +13,18 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.envs; import gplx.*; import gplx.core.*;
import org.junit.*;
public class Process_adp_tst {
private Process_adp_fxt fxt = new Process_adp_fxt();
@Test public void Escape_ampersands_if_process_is_cmd() {
fxt.Test_Escape_ampersands_if_process_is_cmd(Bool_.Y, "cmd" , "/c \"http://a.org?b=c&d=e\"", "/c \"http://a.org?b=c^&d=e\"");
fxt.Test_Escape_ampersands_if_process_is_cmd(Bool_.Y, "cmd1", "/c \"http://a.org?b=c&d=e\"", "/c \"http://a.org?b=c&d=e\"");
fxt.Test_Escape_ampersands_if_process_is_cmd(Bool_.N, "cmd" , "/c \"http://a.org?b=c&d=e\"", "/c \"http://a.org?b=c&d=e\"");
}
}
class Process_adp_fxt {
public void Test_Escape_ampersands_if_process_is_cmd(boolean os_is_wnt, String exe_url, String exe_args, String expd) {
Tfds.Eq(expd, Process_adp.Escape_ampersands_if_process_is_cmd(os_is_wnt, exe_url, exe_args));
}
}
package gplx.core.envs; import gplx.*; import gplx.core.*;
import org.junit.*;
public class Process_adp_tst {
private Process_adp_fxt fxt = new Process_adp_fxt();
@Test public void Escape_ampersands_if_process_is_cmd() {
fxt.Test_Escape_ampersands_if_process_is_cmd(Bool_.Y, "cmd" , "/c \"http://a.org?b=c&d=e\"", "/c \"http://a.org?b=c^&d=e\"");
fxt.Test_Escape_ampersands_if_process_is_cmd(Bool_.Y, "cmd1", "/c \"http://a.org?b=c&d=e\"", "/c \"http://a.org?b=c&d=e\"");
fxt.Test_Escape_ampersands_if_process_is_cmd(Bool_.N, "cmd" , "/c \"http://a.org?b=c&d=e\"", "/c \"http://a.org?b=c&d=e\"");
}
}
class Process_adp_fxt {
public void Test_Escape_ampersands_if_process_is_cmd(boolean os_is_wnt, String exe_url, String exe_args, String expd) {
Tfds.Eq(expd, Process_adp.Escape_ampersands_if_process_is_cmd(os_is_wnt, exe_url, exe_args));
}
}

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.gfo_regys; import gplx.*; import gplx.core.*;
import org.junit.*;
public class GfoRegy_RegDir_tst {
@ -21,7 +21,7 @@ public class GfoRegy_RegDir_tst {
Io_mgr.Instance.InitEngine_mem();
root = Io_url_.mem_dir_("mem/root");
} GfoRegy regy; Io_url root;
@Test public void Basic() {
@Test public void Basic() {
ini_fil("101_tsta.txt");
ini_fil("102_tstb.txt");
ini_fil("103_tstc.png");
@ -31,20 +31,20 @@ public class GfoRegy_RegDir_tst {
tst_Exists("tsta");
tst_Exists("tstb");
}
@Test public void Err_dupe() {
@Test public void Err_dupe() {
ini_fil("101_tsta.txt");
ini_fil("102_tsta.txt");
try {regy.RegDir(root, "*.txt", false, "_", ".");}
catch (Exception e) {Tfds.Err_has(e, GfoRegy.Err_Dupe); return;}
Tfds.Fail_expdError();
}
@Test public void Err_chopBgn() {
@Test public void Err_chopBgn() {
ini_fil("123_");
try {regy.RegDir(root, "*", false, "_", ".");}
catch (Exception e) {Tfds.Err_has(e, GfoRegy.Err_ChopBgn); return;}
Tfds.Fail_expdError();
}
@Test public void Err_chopEnd() {
@Test public void Err_chopEnd() {
ini_fil(".txt");
try {regy.RegDir(root, "*.txt", false, "_", ".");}
catch (Exception e) {Tfds.Err_has(e, GfoRegy.Err_ChopEnd); return;}

@ -13,17 +13,17 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.gfo_regys; import gplx.*; import gplx.core.*;
import org.junit.*;
public class GfoRegy_basic_tst {
@Before public void setup() {
regy = GfoRegy.new_();
} GfoRegy regy;
@Test public void RegObjByType() {
regy.Parsers().Add("Io_url", Io_url_.Parser);
Io_url expd = Io_url_.new_any_("C:\\fil.txt");
regy.RegObjByType("test", expd.Xto_api(), "Io_url");
Io_url actl = (Io_url)regy.FetchValOr("test", Io_url_.Empty);
Tfds.Eq(expd.Xto_api(), actl.Xto_api());
}
}
package gplx.core.gfo_regys; import gplx.*; import gplx.core.*;
import org.junit.*;
public class GfoRegy_basic_tst {
@Before public void setup() {
regy = GfoRegy.new_();
} GfoRegy regy;
@Test public void RegObjByType() {
regy.Parsers().Add("Io_url", Io_url_.Parser);
Io_url expd = Io_url_.new_any_("C:\\fil.txt");
regy.RegObjByType("test", expd.Xto_api(), "Io_url");
Io_url actl = (Io_url)regy.FetchValOr("test", Io_url_.Empty);
Tfds.Eq(expd.Xto_api(), actl.Xto_api());
}
}

@ -1,29 +1,29 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.interfaces; import gplx.*; import gplx.core.*;
import org.junit.*;
public class SrlAble__tst {
@Test public void Basic() {
@Test public void Basic() {
tst_Srl_
( GfoMsg_.new_cast_("itm").Add("key", "a").Add("val", 1)
, "itm:key='a' val='1';"
);
}
@Test public void Depth1_1() {
@Test public void Depth1_1() {
tst_Srl_
( GfoMsg_.new_cast_("itm").Add("key", "a").Add("val", 1).Subs_
( GfoMsg_.new_cast_("itm").Add("key", "aa").Add("val", 11)
@ -33,7 +33,7 @@ public class SrlAble__tst {
)
);
}
@Test public void Depth1_2() {
@Test public void Depth1_2() {
tst_Srl_
( GfoMsg_.new_cast_("itm").Add("key", "a").Add("val", 1).Subs_
( GfoMsg_.new_cast_("itm").Add("key", "aa").Add("val", 11)
@ -47,7 +47,7 @@ public class SrlAble__tst {
)
);
}
@Test public void Depth1_1_2() {
@Test public void Depth1_1_2() {
tst_Srl_
( GfoMsg_.new_cast_("itm").Add("key", "a").Add("val", 1).Subs_
( GfoMsg_.new_cast_("itm").Add("key", "aa").Add("val", 11).Subs_(

@ -1,35 +1,35 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.intls; import gplx.*; import gplx.core.*;
import org.junit.*; import gplx.core.primitives.*;
public class Utf16__tst {
private Utf16__fxt fxt = new Utf16__fxt();
@Test public void Encode_decode() {
@Test public void Encode_decode() {
fxt.Test_encode_decode(162, 194, 162); // cent; ¢
fxt.Test_encode_decode(8364, 226, 130, 172); // euro; €
fxt.Test_encode_decode(150370, 240, 164, 173, 162); // example from [[UTF-8]]; should be encoded as two bytes; 𤭢
fxt.Test_encode_decode(143489, 240, 163, 130, 129); // EX: 駣𣂁脁 DATE:2017-04-22; 𣂁
}
@Test public void Encode_as_bry_by_hex() {
@Test public void Encode_as_bry_by_hex() {
fxt.Test_Encode_hex_to_bry("00", 0);
fxt.Test_Encode_hex_to_bry("41", 65);
fxt.Test_Encode_hex_to_bry("0041", 65);
fxt.Test_Encode_hex_to_bry("00C0", 195, 128);
}
@Test public void Surrogate() {
@Test public void Surrogate() {
fxt.Test_surrogate(0x64321, 0xD950, 0xDF21); // example from w:UTF-16
fxt.Test_surrogate(66643, 55297, 56403); // example from d:Boomerang
}

@ -1,36 +1,36 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.intls; import gplx.*; import gplx.core.*;
import org.junit.*;
public class Utf8__tst {
private Utf8__fxt fxt = new Utf8__fxt();
@Test public void Get_prv_char_pos0() {
@Test public void Get_prv_char_pos0() {
fxt.Test__Get_prv_char_pos0("abcd", 3); // len=1; (note that bry.len = 4)
fxt.Test__Get_prv_char_pos0("a", 0); // len=1; short-String
fxt.Test__Get_prv_char_pos0("abc¢", 3); // len=2; (note that bry.len = 5)
fxt.Test__Get_prv_char_pos0("abc€", 3); // len=3; (note that bry.len = 6)
fxt.Test__Get_prv_char_pos0("abc" + String_.new_u8(Byte_.Ary_by_ints(240, 164, 173, 162)), 3); // len=4; (note that bry.len = 7)
}
@Test public void Increment_char_at_last_pos() {
@Test public void Increment_char_at_last_pos() {
fxt.Test_Increment_char_at_last_pos("a", "b");
fxt.Test_Increment_char_at_last_pos("abc", "abd");
fxt.Test_Increment_char_at_last_pos("É", "Ê"); // len=2
fxt.Test_Increment_char_at_last_pos("€", "₭"); // len=3
}
// @Test public void Increment_char_at_last_pos_exhaustive_check() { // check all values; commented for perf
// @Test public void Increment_char_at_last_pos_exhaustive_check() { // check all values; commented for perf
// Bry_bfr bfr = Bry_bfr_.New();
// int bgn = 32;
// while (true) {

@ -1,20 +1,28 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.ios; import gplx.*; import gplx.core.*;
import gplx.core.strings.*; import gplx.langs.gfs.*;
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.ios; import gplx.GfoMsg;
import gplx.Gfo_invk;
import gplx.Gfo_invk_;
import gplx.GfsCtx;
import gplx.Ordered_hash;
import gplx.Ordered_hash_;
import gplx.UsrDlg_;
import gplx.UsrMsg;
import gplx.core.strings.String_bldr;
import gplx.core.strings.String_bldr_;
public class IoUrlTypeRegy implements Gfo_invk {
public String[] FetchAryOr(String key, String... or) {
IoUrlTypeGrp itm = (IoUrlTypeGrp)hash.Get_by(key);
@ -52,7 +60,7 @@ class IoUrlTypeGrp implements Gfo_invk {
for (int i = 0; i < m.Args_count(); i++) {
String s = m.ReadStr("v");
if (list.Has(s)) {
ctx.Write_warn(UsrMsg.new_("itm already has filter").Add("key", key).Add("filter", s).To_str());
UsrDlg_.Instance.Warn(UsrMsg.new_("itm already has filter").Add("key", key).Add("filter", s).To_str());
list.Del(s);
}
list.Add(s, s);

@ -13,14 +13,14 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.ios; import gplx.*; import gplx.core.*;
import org.junit.*;
public class IoZipWkr_tst {
@Test public void Basic() {
wkr = IoZipWkr.new_(Io_url_.Empty, "e \"{0}\" -o\"{1}\" -y");
tst_Expand_genCmdString(Io_url_.wnt_fil_("C:\\fil1.zip"), Io_url_.wnt_dir_("D:\\out\\"), "e \"C:\\fil1.zip\" -o\"D:\\out\" -y"); // NOTE: not "D:\out\" because .Xto_api
} IoZipWkr wkr;
void tst_Expand_genCmdString(Io_url srcUrl, Io_url trgUrl, String expd) {
Tfds.Eq(expd, wkr.Expand_genCmdString(srcUrl, trgUrl));
}
}
package gplx.core.ios; import gplx.*; import gplx.core.*;
import org.junit.*;
public class IoZipWkr_tst {
@Test public void Basic() {
wkr = IoZipWkr.new_(Io_url_.Empty, "e \"{0}\" -o\"{1}\" -y");
tst_Expand_genCmdString(Io_url_.wnt_fil_("C:\\fil1.zip"), Io_url_.wnt_dir_("D:\\out\\"), "e \"C:\\fil1.zip\" -o\"D:\\out\" -y"); // NOTE: not "D:\out\" because .Xto_api
} IoZipWkr wkr;
void tst_Expand_genCmdString(Io_url srcUrl, Io_url trgUrl, String expd) {
Tfds.Eq(expd, wkr.Expand_genCmdString(srcUrl, trgUrl));
}
}

@ -1,24 +1,24 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.ios; import gplx.*; import gplx.core.*;
import org.junit.*; import gplx.core.envs.*;
public class Io_download_fmt_tst {
Io_download_fmt_fxt fxt = new Io_download_fmt_fxt();
@Before public void init() {fxt.Clear();}
@Test public void Fmt() {
@Test public void Fmt() {
fxt.Clear().Ini("downloading ~{src_name}: ~{prog_left} left (@ ~{prog_rate}); ~{prog_done} of ~{src_len} (~{prog_pct}%)", "http://a.org/b.png", Io_mgr.Len_kb * 10);
fxt.Now_add_f(1000).Prog_done_(1 * Io_mgr.Len_kb).Prog_pct_(1 * 1000).Prog_rate_(Io_mgr.Len_kb).Prog_left_(9 * 1000)
.Prog_msg_("downloading b.png: 09s left (@ 1.000 KBps); 1.000 KB of 10.000 KB (10.00%)")
@ -32,7 +32,7 @@ public class Io_download_fmt_tst {
.Download_(Io_mgr.Len_kb)
;
}
@Test public void Tilde() {
@Test public void Tilde() {
fxt.Clear().Ini("a~b", "http://a.org/b.png", Io_mgr.Len_kb * 10);
}
}

@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.ios; import gplx.*; import gplx.core.*;
import org.junit.*;
public class Io_size__tst {
private Io_size__fxt fxt = new Io_size__fxt();
@Test public void XtoLong() {
@Test public void XtoLong() {
fxt.Test_XtoLong("1", 1);
fxt.Test_XtoLong("1 KB", 1024);
fxt.Test_XtoLong("1 MB", 1024 * 1024);
@ -32,21 +32,21 @@ public class Io_size__tst {
// fxt.Test_XtoLongFail("1.1"); // DELETED:do not check for fractional bytes; EX: 10.7 GB DATE:2015-01-06
// fxt.Test_XtoLongFail("1.51 kb");
}
@Test public void To_str() {
@Test public void To_str() {
fxt.Test_XtoStr(1, "1.000 B");
fxt.Test_XtoStr(1024, "1.000 KB");
fxt.Test_XtoStr(1536, "1.500 KB");
fxt.Test_XtoStr(1024 * 1024, "1.000 MB");
fxt.Test_XtoStr(1016, "1,016.000 B"); // NOTE: 1016 is not 1.016 KB
}
@Test public void Xto_str_full() {
@Test public void Xto_str_full() {
fxt.Test_Xto_str( 500, 1, "#,###", " ", Bool_.Y, "1 KB");
fxt.Test_Xto_str( 1000, 1, "#,###", " ", Bool_.Y, "1 KB");
fxt.Test_Xto_str( 2000, 1, "#,###", " ", Bool_.Y, "2 KB");
fxt.Test_Xto_str( 1234567, 1, "#,###", " ", Bool_.Y, "1,206 KB");
fxt.Test_Xto_str(1234567890, 1, "#,###", " ", Bool_.Y, "1,205,633 KB");
}
@Test public void EqualsTest() {
@Test public void EqualsTest() {
fxt.Test_Equals("1", "1");
fxt.Test_Equals("1 kb", "1 kb");
fxt.Test_Equals("1024", "1 kb");
@ -54,18 +54,18 @@ public class Io_size__tst {
fxt.Test_Equals("1024 kb", "1 mb");
fxt.Test_Equals("1.5 kb", "1536 b");
}
@Test public void To_str_new___b___0() {fxt.Test__to_str_new( 0, 2, "0 B");}
@Test public void To_str_new___b___1() {fxt.Test__to_str_new( 1, 2, "1 B");}
@Test public void To_str_new__kb___1_501__1() {fxt.Test__to_str_new( 1538, 1, "1.5 KB");}
@Test public void To_str_new__kb___1_501__2() {fxt.Test__to_str_new( 1538, 2, "1.50 KB");}
@Test public void To_str_new__kb___1_501__3() {fxt.Test__to_str_new( 1538, 3, "1.501 KB");}
@Test public void To_str_new__kb___1_512__1() {fxt.Test__to_str_new( 1549, 1, "1.5 KB");}
@Test public void To_str_new__kb___1_512__2() {fxt.Test__to_str_new( 1549, 2, "1.51 KB");}
@Test public void To_str_new__kb___1_512__3() {fxt.Test__to_str_new( 1549, 3, "1.512 KB");}
@Test public void To_str_new__mb___1_512__1() {fxt.Test__to_str_new((1024 * 1024) + 536871, 1, "1.5 MB");}
@Test public void To_str_new__mb___1_512__2() {fxt.Test__to_str_new((1024 * 1024) + 536871, 2, "1.51 MB");}
@Test public void To_str_new__mb___1_512__3() {fxt.Test__to_str_new((1024 * 1024) + 536871, 3, "1.512 MB");}
@Test public void To_str_new__gb___1() {fxt.Test__to_str_new(1819264175, 2, "1.69 GB");}
@Test public void To_str_new___b___0() {fxt.Test__to_str_new( 0, 2, "0 B");}
@Test public void To_str_new___b___1() {fxt.Test__to_str_new( 1, 2, "1 B");}
@Test public void To_str_new__kb___1_501__1() {fxt.Test__to_str_new( 1538, 1, "1.5 KB");}
@Test public void To_str_new__kb___1_501__2() {fxt.Test__to_str_new( 1538, 2, "1.50 KB");}
@Test public void To_str_new__kb___1_501__3() {fxt.Test__to_str_new( 1538, 3, "1.501 KB");}
@Test public void To_str_new__kb___1_512__1() {fxt.Test__to_str_new( 1549, 1, "1.5 KB");}
@Test public void To_str_new__kb___1_512__2() {fxt.Test__to_str_new( 1549, 2, "1.51 KB");}
@Test public void To_str_new__kb___1_512__3() {fxt.Test__to_str_new( 1549, 3, "1.512 KB");}
@Test public void To_str_new__mb___1_512__1() {fxt.Test__to_str_new((1024 * 1024) + 536871, 1, "1.5 MB");}
@Test public void To_str_new__mb___1_512__2() {fxt.Test__to_str_new((1024 * 1024) + 536871, 2, "1.51 MB");}
@Test public void To_str_new__mb___1_512__3() {fxt.Test__to_str_new((1024 * 1024) + 536871, 3, "1.512 MB");}
@Test public void To_str_new__gb___1() {fxt.Test__to_str_new(1819264175, 2, "1.69 GB");}
}
class Io_size__fxt {
public void Test_XtoLong(String raw, long expd) {Tfds.Eq(expd, Io_size_.parse_or(raw, Long_.Min_value));}

@ -13,16 +13,16 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.ios.streams; import gplx.*; import gplx.core.*; import gplx.core.ios.*;
import org.junit.*; //using System.IO; /*Stream*/
public class IoStream_mem_tst {
@Test public void Write() { // confirm that changes written to Stream acquired via .AdpObj are written to IoStream_mem.Buffer
IoStream_mem stream = IoStream_mem.wtr_data_(Io_url_.Empty, 0);
byte[] data = Bry_.New_by_ints(1);
stream.Write(data, 0, Array_.Len(data));
Tfds.Eq(1L , stream.Len());
Tfds.Eq((byte)1 , stream.Buffer()[0]);
stream.Rls();
}
}
package gplx.core.ios.streams; import gplx.*; import gplx.core.*; import gplx.core.ios.*;
import org.junit.*; //using System.IO; /*Stream*/
public class IoStream_mem_tst {
@Test public void Write() { // confirm that changes written to Stream acquired via .AdpObj are written to IoStream_mem.Buffer
IoStream_mem stream = IoStream_mem.wtr_data_(Io_url_.Empty, 0);
byte[] data = Bry_.New_by_ints(1);
stream.Write(data, 0, Array_.Len(data));
Tfds.Eq(1L , stream.Len());
Tfds.Eq((byte)1 , stream.Buffer()[0]);
stream.Rls();
}
}

@ -1,27 +1,27 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.ios.streams; import gplx.*; import gplx.core.*; import gplx.core.ios.*;
import org.junit.*;
public class IoStream_mock_tst {
@Before public void init() {fxt.Clear();} IoStream_mock_fxt fxt = new IoStream_mock_fxt();
@Test public void Basic() {
@Test public void Basic() {
fxt.Init_src_str_("abcde").Init_trg_len_(5).Init_rdr_limit_(2).Init_read_len_(2);
fxt.Test_read("ab").Test_read("cd").Test_read("e");
}
@Test public void Read_limit() {
@Test public void Read_limit() {
fxt.Init_src_str_("abcde").Init_trg_len_(5).Init_rdr_limit_(2).Init_read_len_(4);
fxt.Test_read("ab").Test_read("cd").Test_read("e");
}

@ -1,24 +1,24 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.ios.streams; import gplx.*; import gplx.core.*; import gplx.core.ios.*;
import org.junit.*;
public class Io_stream_rdr__tst {
@Before public void init() {fxt.Clear();} private Io_stream_rdr__fxt fxt = new Io_stream_rdr__fxt();
@After public void term() {fxt.Rls();}
@Test public void Bz2_read() {
@Test public void Bz2_read() {
fxt .Init_stream("abcd") // read everything at once
.Expd_bytes_read(4).Test_read(0, 4, "abcd");
fxt .Init_stream("abcd") // read in steps

@ -13,17 +13,17 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.ios.zips; import gplx.*; import gplx.core.*; import gplx.core.ios.*;
import org.junit.*;
public class Io_zip_mgr_tst {
@Test public void Zip_unzip() {
Zip_unzip_tst("abcdefghijklmnopqrstuvwxyz");
}
private void Zip_unzip_tst(String s) {
Io_zip_mgr zip_mgr = Io_zip_mgr_base.Instance;
byte[] src = Bry_.new_a7(s);
byte[] zip = zip_mgr.Zip_bry(src, 0, src.length);
byte[] unz = zip_mgr.Unzip_bry(zip, 0, zip.length);
Tfds.Eq_ary(src, unz);
}
}
package gplx.core.ios.zips; import gplx.*; import gplx.core.*; import gplx.core.ios.*;
import org.junit.*;
public class Io_zip_mgr_tst {
@Test public void Zip_unzip() {
Zip_unzip_tst("abcdefghijklmnopqrstuvwxyz");
}
private void Zip_unzip_tst(String s) {
Io_zip_mgr zip_mgr = Io_zip_mgr_base.Instance;
byte[] src = Bry_.new_a7(s);
byte[] zip = zip_mgr.Zip_bry(src, 0, src.length);
byte[] unz = zip_mgr.Unzip_bry(zip, 0, zip.length);
Tfds.Eq_ary(src, unz);
}
}

@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.js; import gplx.*; import gplx.core.*;
import org.junit.*;
public class Js_wtr_tst {
@Before public void Init() {fxt.Clear();} private Js_wtr_fxt fxt = new Js_wtr_fxt();
@Test public void Basic() {
@Test public void Basic() {
fxt.Test_write_val_html("abc" , "'abc'");
fxt.Test_write_val_html("a'b" , "'a\\'b'");
fxt.Test_write_val_html("a\"b" , "'a\\\"b'");

@ -1,27 +1,27 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.lists; import gplx.*; import gplx.core.*;
import org.junit.*;
public class List_adp_sorter_tst {
@Test public void Basic() {
@Test public void Basic() {
Object[] src = new Object[] {0,8,1,7,2,6,3,5,4};
List_adp_sorter.new_().Sort(src, src.length);
Tfds.Eq_ary(src, Sequential(0, 8));
}
@Test public void Basic2() {
@Test public void Basic2() {
Object[] src = new Object[] {"0","8","1","7","2","6","3","5","4"};
List_adp_sorter.new_().Sort(src, src.length);
Tfds.Eq_ary(src, new Object[] {"0","1","2","3","4","5","6","7","8"});

@ -13,19 +13,19 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.lists; import gplx.*; import gplx.core.*;
import org.junit.*;
package gplx.core.lists; import gplx.*; import gplx.core.*;
import org.junit.*;
public class StackAdp_tst {
@Test public void XtoList() {
tst_XtoList(1, 2, 3);
}
void tst_XtoList(int... ary) {
StackAdp stack = StackAdp_.new_();
for (int i : ary)
stack.Push(i);
List_adp list = stack.XtoList();
int[] actl = (int[])list.To_ary(int.class);
for (int i = 0; i < ary.length; i++)
Tfds.Eq(ary[i], actl[i]);
}
}
@Test public void XtoList() {
tst_XtoList(1, 2, 3);
}
void tst_XtoList(int... ary) {
StackAdp stack = StackAdp_.new_();
for (int i : ary)
stack.Push(i);
List_adp list = stack.XtoList();
int[] actl = (int[])list.To_ary(int.class);
for (int i = 0; i < ary.length; i++)
Tfds.Eq(ary[i], actl[i]);
}
}

@ -1,28 +1,28 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.lists.rings; import gplx.*; import gplx.core.*; import gplx.core.lists.*;
import org.junit.*; import gplx.core.tests.*;
public class Ring__long__tst {
private final Ring__long__fxt fxt = new Ring__long__fxt();
@Test public void Basic__1() {fxt.Clear().Add(1) .Test__to_ary(1);}
@Test public void Basic__2() {fxt.Clear().Add(1, 2) .Test__to_ary(1, 2);}
@Test public void Basic__3() {fxt.Clear().Add(1, 2, 3) .Test__to_ary(1, 2, 3);}
@Test public void Wrap__1() {fxt.Clear().Add(1, 2, 3, 4) .Test__to_ary(2, 3, 4);}
@Test public void Wrap__2() {fxt.Clear().Add(1, 2, 3, 4, 5) .Test__to_ary(3, 4, 5);}
@Test public void Wrap__3() {fxt.Clear().Add(1, 2, 3, 4, 5, 6) .Test__to_ary(4, 5, 6);}
@Test public void Basic__1() {fxt.Clear().Add(1) .Test__to_ary(1);}
@Test public void Basic__2() {fxt.Clear().Add(1, 2) .Test__to_ary(1, 2);}
@Test public void Basic__3() {fxt.Clear().Add(1, 2, 3) .Test__to_ary(1, 2, 3);}
@Test public void Wrap__1() {fxt.Clear().Add(1, 2, 3, 4) .Test__to_ary(2, 3, 4);}
@Test public void Wrap__2() {fxt.Clear().Add(1, 2, 3, 4, 5) .Test__to_ary(3, 4, 5);}
@Test public void Wrap__3() {fxt.Clear().Add(1, 2, 3, 4, 5, 6) .Test__to_ary(4, 5, 6);}
}
class Ring__long__fxt {
private Ring__long ring = new Ring__long(3);

@ -1,24 +1,24 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.lists.rings; import gplx.*; import gplx.core.*; import gplx.core.lists.*;
import org.junit.*;
public class Ring__string__tst {
private final Ring__string__fxt fxt = new Ring__string__fxt();
@Before public void init() {fxt.Clear();}
@Test public void Basic() {
@Test public void Basic() {
fxt.Clear().Max_(3).Push_many("a") .Expd("a");
fxt.Clear().Max_(3).Push_many("a", "b") .Expd("a", "b");
fxt.Clear().Max_(3).Push_many("a", "b", "c") .Expd("a", "b", "c");

@ -1,33 +1,33 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.log_msgs; import gplx.*; import gplx.core.*;
import org.junit.*;
public class Gfo_msg_root_tst {
Gfo_msg_root_fxt fxt = new Gfo_msg_root_fxt();
@Before public void setup() {fxt.Reset();}
@Test public void Str() {
@Test public void Str() {
fxt.Clear().Expd_data_str_("failed a0 b0").Tst_data_new_many("proj.cls.proc", "err_0", "failed ~{0} ~{1}", "a0", "b0");
fxt.Clear().Expd_data_str_("failed a1 b1").Tst_data_new_many("proj.cls.proc", "err_0", "failed ~{0} ~{1}", "a1", "b1");
}
// @Test public void Item() { // DISABLED: no longer registering items with owner;
// @Test public void Item() { // DISABLED: no longer registering items with owner;
// fxt.Clear().Expd_item_uid_(0).Expd_item_fmtr_arg_exists_(Bool_.Y).Tst_data_new_many("proj.cls.proc", "err_0", "failed ~{0} ~{1}", "a0", "b0");
// fxt.Clear().Expd_item_uid_(1).Expd_item_fmtr_arg_exists_(Bool_.N).Tst_data_new_many("proj.cls.proc", "err_1", "failed");
// fxt.Clear().Expd_item_uid_(0).Tst_data_new_many("proj.cls.proc", "err_0", "failed ~{0} ~{1}", "a0", "b0"); // make sure item_uid stays the same
// }
@Test public void Cache() {
@Test public void Cache() {
fxt.Mgr().Data_ary_len_(2);
fxt.Clear().Expd_data_uid_(0).Tst_data_new_many("x", "err_0", "a");
fxt.Clear().Expd_data_uid_(1).Tst_data_new_many("x", "err_0", "b");

@ -1,25 +1,25 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.primitives; import gplx.*; import gplx.core.*;
import org.junit.*;
public class EnmParser_tst {
@Before public void setup() {
parser = EnmMgr.new_();
}
@Test public void Basic() { // 1,2,4,8
@Test public void Basic() { // 1,2,4,8
parser.BitRngEnd_(8);
run_Reg(0, "zero");
run_Reg(1, "one");
@ -32,7 +32,7 @@ public class EnmParser_tst {
tst_Convert("eight", 8);
tst_Convert("one+eight", 9);
}
@Test public void Keys() {
@Test public void Keys() {
parser.BitRngBgn_(65536).BitRngEnd_(262144);
run_Reg( 65, "a");
run_Reg( 65536, "shift");
@ -43,7 +43,7 @@ public class EnmParser_tst {
tst_Convert("ctrl+a", 65 + 131072);
tst_Convert("shift+ctrl+a", 65 + 65536 + 131072);
}
@Test public void Prefix() {
@Test public void Prefix() {
parser.Prefix_("key.").BitRngBgn_(128).BitRngEnd_(128);
run_Reg(65, "a");
tst_Convert("key.a", 65);

@ -1,193 +1,195 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.primitives;
import gplx.Byte_ascii;
import gplx.Decimal_adp;
import gplx.Decimal_adp_;
import gplx.Int_;
import gplx.Math_;
public class Gfo_number_parser {
public int Rv_as_int() {return (int)num_val;} private long num_val = 0;
public long Rv_as_long() {return num_val;}
public Decimal_adp Rv_as_dec() {return dec_val == null ? Decimal_adp_.long_(num_val) : dec_val;} private Decimal_adp dec_val = null;
public boolean Is_int() {return dec_val == null && (num_val >= Int_.Min_value && num_val <= Int_.Max_value);}
public boolean Has_err() {return has_err;} private boolean has_err;
public boolean Has_frac() {return has_frac;} private boolean has_frac;
public boolean Hex_enabled() {return hex_enabled;} public Gfo_number_parser Hex_enabled_(boolean v) {hex_enabled = v; return this;} private boolean hex_enabled;
public Gfo_number_parser Ignore_chars_(byte[] v) {this.ignore_chars = v; return this;} private byte[] ignore_chars;
public Gfo_number_parser Ignore_space_at_end_y_() {this.ignore_space_at_end = true; return this;} private boolean ignore_space_at_end;
public void Clear() {
ignore_chars = null;
}
public Gfo_number_parser Parse(byte[] src) {return Parse(src, 0, src.length);}
public Gfo_number_parser Parse(byte[] ary, int bgn, int end) {
int loop_bgn = end - 1, loop_end = bgn - 1, exp_multiplier = 1, factor = 10;
long multiplier = 1, frc_multiplier = 1;
num_val = 0; dec_val = null; boolean comma_nil = true;
long frc_int = 0;
has_err = false; has_frac = false; boolean has_exp = false, has_neg = false, exp_neg = false, has_plus = false, has_num = false;
boolean input_is_hex = false;
if (hex_enabled) {
if (loop_end + 2 < end) { // ArrayOutOfBounds check
byte b_2 = ary[loop_end + 2];
switch (b_2) {
case Byte_ascii.Ltr_x:
case Byte_ascii.Ltr_X: // is 2nd char x?
if (ary[loop_end + 1] == Byte_ascii.Num_0) { // is 1st char 0?
factor = 16;
input_is_hex = true;
}
break;
default:
break;
}
}
}
for (int i = loop_bgn; i > loop_end; i--) {
byte cur = ary[i];
switch (cur) {
case Byte_ascii.Num_0:
case Byte_ascii.Num_1:
case Byte_ascii.Num_2:
case Byte_ascii.Num_3:
case Byte_ascii.Num_4:
case Byte_ascii.Num_5:
case Byte_ascii.Num_6:
case Byte_ascii.Num_7:
case Byte_ascii.Num_8:
case Byte_ascii.Num_9:
num_val += (cur - Byte_ascii.Num_0) * multiplier;
multiplier *= factor;
has_num = true;
break;
case Byte_ascii.Dot:
if (has_frac) return Has_err_y_();
frc_int = num_val;
num_val = 0;
frc_multiplier = multiplier;
multiplier = 1;
has_frac = true;
break;
case Byte_ascii.Comma:
if (comma_nil)
comma_nil = false;
else
return Has_err_y_();
break;
case Byte_ascii.Dash:
if (has_neg) return Has_err_y_();
has_neg = true;
break;
case Byte_ascii.Space:
if (i == bgn) {} // space at bgn
else if (i == end - 1 && ignore_space_at_end) {} // ignore space at end; DATE:2015-04-29
else
return Has_err_y_();
break;
case Byte_ascii.Plus:
if (has_plus) return Has_err_y_();
has_plus = true;
break;
case Byte_ascii.Ltr_e:
case Byte_ascii.Ltr_E:
if (input_is_hex) {
num_val += 14 * multiplier; // NOTE: 14=value of e/E
multiplier *= factor;
has_num = true;
}
else {
if (has_exp) return Has_err_y_();
exp_neg = has_neg;
exp_multiplier = (int)Math_.Pow(10, num_val);
num_val = 0;
multiplier = 1;
has_exp = true;
has_neg = false;
has_plus = false; // allow +1E+2
has_num = false; // 2020-09-07|ISSUE#:795|scientific notation requires coefficient; set has_num to false which will fail below if no coefficient
}
break;
case Byte_ascii.Ltr_A:
case Byte_ascii.Ltr_B:
case Byte_ascii.Ltr_C:
case Byte_ascii.Ltr_D:
case Byte_ascii.Ltr_F:
if (input_is_hex) {
num_val += (cur - Byte_ascii.Ltr_A + 10) * multiplier;
multiplier *= factor;
has_num = true;
}
else
return Has_err_y_();
break;
case Byte_ascii.Ltr_a:
case Byte_ascii.Ltr_b:
case Byte_ascii.Ltr_c:
case Byte_ascii.Ltr_d:
case Byte_ascii.Ltr_f:
if (input_is_hex) {
num_val += (cur - Byte_ascii.Ltr_a + 10) * multiplier;
multiplier *= factor;
has_num = true;
}
else
return Has_err_y_();
break;
case Byte_ascii.Ltr_x:
case Byte_ascii.Ltr_X:
if (input_is_hex)
return (factor == 16) ? this : Has_err_y_(); // check for '0x'
else
return Has_err_y_();
default:
if (ignore_chars != null) {
int ignore_chars_len = ignore_chars.length;
boolean ignored = false;
for (int j = 0; j < ignore_chars_len; ++j) {
if (cur == ignore_chars[j]) {
ignored = true;
break;
}
}
if (ignored) continue;
}
return Has_err_y_();
}
}
if (!has_num) return Has_err_y_(); // handles situations wherein just symbols; EX: "+", ".", "-.", " , " etc.
if (has_frac) {
long full_val = (((num_val * frc_multiplier) + frc_int));
if (has_neg) full_val *= -1;
if (has_exp) {
if (exp_neg) frc_multiplier *= exp_multiplier; // divide, so apply to frc
else full_val *= exp_multiplier; // multiply, so apply to full_val
}
dec_val = Decimal_adp_.divide_(full_val, frc_multiplier);
}
else {
if (has_neg) num_val *= -1;
if (has_exp) {
num_val = exp_neg
? num_val / exp_multiplier
: num_val * exp_multiplier;
}
}
return this;
}
private Gfo_number_parser Has_err_y_() {has_err = true; return this;}
}
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.primitives;
import gplx.Byte_ascii;
import gplx.Decimal_adp;
import gplx.Decimal_adp_;
import gplx.Int_;
import gplx.Math_;
public class Gfo_number_parser {
public int Rv_as_int() {return (int)num_val;} private long num_val = 0;
public long Rv_as_long() {return num_val;}
public Decimal_adp Rv_as_dec() {return dec_val == null ? Decimal_adp_.long_(num_val) : dec_val;} private Decimal_adp dec_val = null;
public boolean Is_int() {return dec_val == null && (num_val >= Int_.Min_value && num_val <= Int_.Max_value);}
public boolean Is_long() {return dec_val == null;}
public boolean Has_err() {return has_err;} private boolean has_err;
public boolean Has_frac() {return has_frac;} private boolean has_frac;
public boolean Hex_enabled() {return hex_enabled;} public Gfo_number_parser Hex_enabled_(boolean v) {hex_enabled = v; return this;} private boolean hex_enabled;
public Gfo_number_parser Ignore_chars_(byte[] v) {this.ignore_chars = v; return this;} private byte[] ignore_chars;
public Gfo_number_parser Ignore_space_at_end_y_() {this.ignore_space_at_end = true; return this;} private boolean ignore_space_at_end;
public Gfo_number_parser Clear() {
ignore_chars = null;
return this;
}
public Gfo_number_parser Parse(byte[] src) {return Parse(src, 0, src.length);}
public Gfo_number_parser Parse(byte[] ary, int bgn, int end) {
int loop_bgn = end - 1, loop_end = bgn - 1, exp_multiplier = 1, factor = 10;
long multiplier = 1, frc_multiplier = 1;
num_val = 0; dec_val = null; boolean comma_nil = true;
long frc_int = 0;
has_err = false; has_frac = false; boolean has_exp = false, has_neg = false, exp_neg = false, has_plus = false, has_num = false;
boolean input_is_hex = false;
if (hex_enabled) {
if (loop_end + 2 < end) { // ArrayOutOfBounds check
byte b_2 = ary[loop_end + 2];
switch (b_2) {
case Byte_ascii.Ltr_x:
case Byte_ascii.Ltr_X: // is 2nd char x?
if (ary[loop_end + 1] == Byte_ascii.Num_0) { // is 1st char 0?
factor = 16;
input_is_hex = true;
}
break;
default:
break;
}
}
}
for (int i = loop_bgn; i > loop_end; i--) {
byte cur = ary[i];
switch (cur) {
case Byte_ascii.Num_0:
case Byte_ascii.Num_1:
case Byte_ascii.Num_2:
case Byte_ascii.Num_3:
case Byte_ascii.Num_4:
case Byte_ascii.Num_5:
case Byte_ascii.Num_6:
case Byte_ascii.Num_7:
case Byte_ascii.Num_8:
case Byte_ascii.Num_9:
num_val += (cur - Byte_ascii.Num_0) * multiplier;
multiplier *= factor;
has_num = true;
break;
case Byte_ascii.Dot:
if (has_frac) return Has_err_y_();
frc_int = num_val;
num_val = 0;
frc_multiplier = multiplier;
multiplier = 1;
has_frac = true;
break;
case Byte_ascii.Comma:
if (comma_nil)
comma_nil = false;
else
return Has_err_y_();
break;
case Byte_ascii.Dash:
if (has_neg) return Has_err_y_();
has_neg = true;
break;
case Byte_ascii.Space:
if (i == bgn) {} // space at bgn
else if (i == end - 1 && ignore_space_at_end) {} // ignore space at end; DATE:2015-04-29
else
return Has_err_y_();
break;
case Byte_ascii.Plus:
if (has_plus) return Has_err_y_();
has_plus = true;
break;
case Byte_ascii.Ltr_e:
case Byte_ascii.Ltr_E:
if (input_is_hex) {
num_val += 14 * multiplier; // NOTE: 14=value of e/E
multiplier *= factor;
has_num = true;
}
else {
if (has_exp) return Has_err_y_();
exp_neg = has_neg;
exp_multiplier = (int)Math_.Pow(10, num_val);
num_val = 0;
multiplier = 1;
has_exp = true;
has_neg = false;
has_plus = false; // allow +1E+2
has_num = false; // 2020-09-07|ISSUE#:795|scientific notation requires coefficient; set has_num to false which will fail below if no coefficient
}
break;
case Byte_ascii.Ltr_A:
case Byte_ascii.Ltr_B:
case Byte_ascii.Ltr_C:
case Byte_ascii.Ltr_D:
case Byte_ascii.Ltr_F:
if (input_is_hex) {
num_val += (cur - Byte_ascii.Ltr_A + 10) * multiplier;
multiplier *= factor;
has_num = true;
}
else
return Has_err_y_();
break;
case Byte_ascii.Ltr_a:
case Byte_ascii.Ltr_b:
case Byte_ascii.Ltr_c:
case Byte_ascii.Ltr_d:
case Byte_ascii.Ltr_f:
if (input_is_hex) {
num_val += (cur - Byte_ascii.Ltr_a + 10) * multiplier;
multiplier *= factor;
has_num = true;
}
else
return Has_err_y_();
break;
case Byte_ascii.Ltr_x:
case Byte_ascii.Ltr_X:
if (input_is_hex)
return (factor == 16) ? this : Has_err_y_(); // check for '0x'
else
return Has_err_y_();
default:
if (ignore_chars != null) {
int ignore_chars_len = ignore_chars.length;
boolean ignored = false;
for (int j = 0; j < ignore_chars_len; ++j) {
if (cur == ignore_chars[j]) {
ignored = true;
break;
}
}
if (ignored) continue;
}
return Has_err_y_();
}
}
if (!has_num) return Has_err_y_(); // handles situations wherein just symbols; EX: "+", ".", "-.", " , " etc.
if (has_frac) {
long full_val = (((num_val * frc_multiplier) + frc_int));
if (has_neg) full_val *= -1;
if (has_exp) {
if (exp_neg) frc_multiplier *= exp_multiplier; // divide, so apply to frc
else full_val *= exp_multiplier; // multiply, so apply to full_val
}
dec_val = Decimal_adp_.divide_(full_val, frc_multiplier);
}
else {
if (has_neg) num_val *= -1;
if (has_exp) {
num_val = exp_neg
? num_val / exp_multiplier
: num_val * exp_multiplier;
}
}
return this;
}
private Gfo_number_parser Has_err_y_() {has_err = true; return this;}
}

@ -0,0 +1,59 @@
package gplx.core.primitives;
import gplx.Err_;
public class Int_ary {
private int[] ary; private int len, max;
public Int_ary(int max) {
this.len = 0;
this.max = max;
this.ary = new int[max];
}
public int[] Ary() {return ary;}
public void Clear() {
for (int i = 0; i < len; ++i)
ary[i] = 0;
len = 0;
}
public int Len() {return len;}
public int Get_at_or_fail(int i) {
if (i > -1 && i < len) return ary[i];
else throw Err_.new_("core.int_ary", "index is invalid", "i", i, "len", len);
}
public void Add(int v) {
if (len == max) {
int new_max = max * 2;
int[] new_ary = new int[new_max];
for (int i = 0; i < len; ++i)
new_ary[i] = ary[i];
this.ary = new_ary;
this.max = new_max;
}
ary[len] = v;
++len;
}
public int Pop_or_fail() {
if (len == 0) throw Err_.new_("core.int_ary", "stack is empty");
return Pop_or(-1);
}
public int Pop_or(int or) {
if (len == 0) return or;
int rv = ary[len - 1];
--len;
return rv;
}
public int Idx_of(int find) {
for (int i = len - 1; i > -1; --i) {
if (ary[i] == find) return i;
}
return Not_found;
}
public boolean Del_from_end(int find) {
int find_idx = Idx_of(find); if (find_idx == Not_found) return false;
int last_idx = len - 1;
for (int i = find_idx; i < last_idx; ++i)
ary[i] = ary[i + 1];
ary[last_idx] = 0;
--len;
return true;
}
public static final int Not_found = -1;
}

@ -0,0 +1,38 @@
package gplx.core.security.algos.gplx_crypto; import gplx.Int_;
public class Crc32 {
int crc = 0; /** The crc data checksum so far. */
public String CalcHash(byte[] ary) {
Reset();
Calc(ary);
return Int_.To_str_hex(Crc());
}
public int Crc() {return crc;}//(int)(crc & 0xffffffffL);}
public void Reset() {crc = 0;}
public void Calc(int val) {
int tmp = ~crc;
tmp = CrcTable[(tmp ^ val) & 0xff] ^ (0x7FFFFFFF & tmp >>> 8); //#<>(int)((uint)tmp >> 8)~tmp >>> 8
crc = ~tmp;
}
public void Calc(byte[] ary) {Calc(ary, 0, ary.length);}
public void Calc(byte[] ary, int off, int len) {
int tmp = ~crc;
while (--len >= 0)
tmp = CrcTable[(tmp ^ ary[off++]) & 0xff] ^ (0x7FFFFFFF & tmp >>> 8);//#<>(int)((uint)tmp >> 8)~tmp >>> 8
crc = ~tmp;
}
static int[] CrcTable = CrcTable_make();
static int[] CrcTable_make () {
int[] rv = new int[256];
for (int i = 0; i < 256; i++) {
int tmp = i;
for (int k = 8; --k >= 0;) {
if ((tmp & 1) != 0)
tmp = (int)(0xedb88320 ^ tmp >>> 1); //#<>(int)((uint)tmp >> 1)~tmp >>> 1
else
tmp = tmp >>> 1; //#<>(int)((uint)tmp >> 1)~tmp >>> 1
}
rv[i] = tmp;
}
return rv;
}
}

@ -0,0 +1,66 @@
package gplx.core.security.algos.gplx_crypto; import gplx.Bry_;
import gplx.Int_;
import gplx.Io_mgr;
import gplx.Io_url;
import gplx.String_;
import gplx.Tfds;
import gplx.core.consoles.Console_adp__sys;
import gplx.core.ios.streams.IoStream;
import gplx.core.ios.streams.IoStream_;
import gplx.core.strings.String_bldr;
import gplx.core.strings.String_bldr_;
import org.junit.Test;
public class Crc32_tst {
Crc32 crc32 = new Crc32();
@Test public void Basic() {
tst_Crc32("00000000", "");
tst_Crc32("E8B7BE43", "a");
tst_Crc32("4C2750BD", "abcdefghijklmnopqrstuvwxyz");
tst_Crc32("ABF77822", "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
}
void tst_Crc32(String expd, String dat) {Tfds.Eq(expd, crc32.CalcHash(Bry_.new_u8(dat)), expd);}
}
class Crc32_mgr {
Crc32 crc32 = new Crc32();
public void SearchDir(Io_url dir) {
Io_url[] urlAry = Io_mgr.Instance.QueryDir_args(dir).Recur_().ExecAsUrlAry();
String_bldr sb = String_bldr_.new_();
for (Io_url url : urlAry) {
String expd = Extract(url);
String actl = expd == String_.Empty ? String_.Empty : CheckFile(url);
String status = Status(expd, actl);
sb.Add(status).Add("|");
sb.Add(url.Xto_api()).Add("|");
sb.Add(expd).Add("|"); sb.Add(actl).Add_char_nl();
Console_adp__sys.Instance.Write_fmt_w_nl("{0} {1} {2}", status, actl, url.NameOnly());
}
Io_mgr.Instance.SaveFilStr(dir.GenSubFil("results.csv"), sb.To_str());
}
String Status(String expd, String actl) {
if (expd == String_.Empty) return "none";
return String_.Eq(expd, actl) ? "ok " : "BAD";
}
String Extract(Io_url url) {
String urlStr = url.NameOnly();
int bgnPos = String_.FindBwd(urlStr, "["); if (bgnPos == String_.Find_none) return String_.Empty;
int endPos = String_.FindFwd(urlStr, "]", bgnPos); if (endPos == String_.Find_none) return String_.Empty;
String crc = String_.Mid(urlStr, bgnPos + 1, endPos);
return String_.Upper(crc);
}
String CheckFile(Io_url url) {
IoStream stream = IoStream_.Null;
int pos = 0, readLen = 0;
crc32.Reset();
byte[] ary = new byte[256 * 256];
try {
stream = Io_mgr.Instance.OpenStreamRead(url);
while (true) {
readLen = stream.Read(ary, pos, ary.length);
crc32.Calc(ary, 0, readLen);
if (readLen < 1) break;
}
}
finally {stream.Rls();}
return Int_.To_str_hex(crc32.Crc());
}
}

@ -1,34 +1,34 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.security.algos.gplx_crypto; import gplx.*; import gplx.core.*; import gplx.core.security.*; import gplx.core.security.algos.*;
import org.junit.*; import gplx.core.consoles.*; import gplx.core.ios.*; /*IoStream*/
public class Hash_algo__tth_192__tst { // REF: http://open-content.net/specs/draft-jchapweske-thex-02.html; DC++ 0.698
private final Hash_algo__fxt fxt = new Hash_algo__fxt(Hash_algo_.New__tth_192());
@Test public void Empty() {fxt.Test__hash("LWPNACQDBZRYXW3VHJVCJ64QBZNGHOHHHZWCLNQ", "");}
@Test public void Null__1() {fxt.Test__hash("VK54ZIEEVTWNAUI5D5RDFIL37LX2IQNSTAXFKSA", "\0");}
@Test public void ab() {fxt.Test__hash("XQXRSGMB3PSN2VGZYJMNJG6SOOQ3JIGQHD2I6PQ", "ab");}
@Test public void abc() {fxt.Test__hash("ASD4UJSEH5M47PDYB46KBTSQTSGDKLBHYXOMUIA", "abc");}
@Test public void abde() {fxt.Test__hash("SQF2PFTVIFRR5KJSI45IDENXMB43NI7EIXYGHGI", "abcd");}
@Test public void abcde() {fxt.Test__hash("SKGLNP5WV7ZUMF6IUK5CYXBE3PI4C6PHWNVM2YQ", "abcde");}
@Test public void abcdefghi() {fxt.Test__hash("RUIKHZFO4NIY6NNUHJMAC2I26U3U65FZWCO3UFY", "abcdefghi");}
@Test public void Empty() {fxt.Test__hash("LWPNACQDBZRYXW3VHJVCJ64QBZNGHOHHHZWCLNQ", "");}
@Test public void Null__1() {fxt.Test__hash("VK54ZIEEVTWNAUI5D5RDFIL37LX2IQNSTAXFKSA", "\0");}
@Test public void ab() {fxt.Test__hash("XQXRSGMB3PSN2VGZYJMNJG6SOOQ3JIGQHD2I6PQ", "ab");}
@Test public void abc() {fxt.Test__hash("ASD4UJSEH5M47PDYB46KBTSQTSGDKLBHYXOMUIA", "abc");}
@Test public void abde() {fxt.Test__hash("SQF2PFTVIFRR5KJSI45IDENXMB43NI7EIXYGHGI", "abcd");}
@Test public void abcde() {fxt.Test__hash("SKGLNP5WV7ZUMF6IUK5CYXBE3PI4C6PHWNVM2YQ", "abcde");}
@Test public void abcdefghi() {fxt.Test__hash("RUIKHZFO4NIY6NNUHJMAC2I26U3U65FZWCO3UFY", "abcdefghi");}
// @Test
public void a__x_1024() {fxt.Test__hash("L66Q4YVNAFWVS23X2HJIRA5ZJ7WXR3F26RSASFA", String_.Repeat("A", 1024));}
// @Test
public void a__x_1025() {fxt.Test__hash("PZMRYHGY6LTBEH63ZWAHDORHSYTLO4LEFUIKHWY", String_.Repeat("A", 1025));}
// @Test
// @Test
public void A__Pow27() {fxt.Test__hash("QNIJO36QDIQREUT3HWK4MDVKD2T6OENAEKYADTQ", String_.Repeat("A", (int)Math_.Pow(2, 27)));
}
}

@ -1,22 +1,22 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.security.algos.gplx_crypto; import gplx.*; import gplx.core.*; import gplx.core.security.*; import gplx.core.security.algos.*;
import org.junit.*;
public class Hash_algo__tth_192_tree_tst {
@Test public void CalcRecursiveHalves() {
@Test public void CalcRecursiveHalves() {
tst_CalcRecursiveHalves(129, 128);
tst_CalcRecursiveHalves(128, 127);
tst_CalcRecursiveHalves(100, 99);
@ -29,7 +29,7 @@ public class Hash_algo__tth_192_tree_tst {
tst_CalcRecursiveHalves(1, 0);
tst_CalcRecursiveHalves(0, 0);
}
@Test public void CalcWorkUnits() {
@Test public void CalcWorkUnits() {
tst_CalcWorkUnits(101, 21); // leafs; 10 full, 1 part (+11) -> reduce 11 to 5+1 (+5) -> reduce 6 to 3 (+3) -> reduce 3 to 1+1 (+1) -> reduce 2 to 1 (+1)
tst_CalcWorkUnits(100, 19); // leafs; 10 full (+10) -> reduce 10 to 5 (+5) -> reduce 5 to 2+1 (+2) -> reduce 3 to 1+1 (+1) -> reduce 2 to 1 (+1)
tst_CalcWorkUnits(30, 5); // leafs; 3 full (+3) -> reduce 3 to 1+1 (+1) -> reduce 2 to 1 (+1)

@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.security.algos.gplx_crypto; import gplx.*; import gplx.core.*; import gplx.core.security.*; import gplx.core.security.algos.*;
import org.junit.*; import gplx.core.consoles.*; import gplx.core.ios.streams.*; /*IoStream*/
public class Hash_console_wtr_tst {
private final Hash_console_wtr_fxt fxt = new Hash_console_wtr_fxt();
@Test public void Basic() {
@Test public void Basic() {
fxt.Test__Status(10, " - hash: 100%");
fxt.Test__Status(11, " - hash: 66%");
fxt.Test__Status(30, " - hash: 40%", " - hash: 60%", " - hash: 100%");

@ -1,31 +1,31 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.security.algos.jre; import gplx.*; import gplx.core.*; import gplx.core.security.*; import gplx.core.security.algos.*;
import org.junit.*;
public class Jre_hash_algo__md5__tst { // REF: https://www.cosic.esat.kuleuven.be/nessie/testvectors/hash/md5/Md5-128.unverified.test-vectors
private final Hash_algo__fxt fxt = new Hash_algo__fxt(Hash_algo_.New__md5());
@Test public void Empty() {fxt.Test__hash("d41d8cd98f00b204e9800998ecf8427e", "");}
@Test public void a() {fxt.Test__hash("0cc175b9c0f1b6a831c399e269772661", "a");}
@Test public void abc() {fxt.Test__hash("900150983cd24fb0d6963f7d28e17f72", "abc");}
@Test public void message_digest() {fxt.Test__hash("f96b697d7cb7938d525a2f31aaf161d0", "message digest");}
@Test public void a_z() {fxt.Test__hash("c3fcd3d76192e4007dfb496cca67e13b", "abcdefghijklmnopqrstuvwxyz");}
@Test public void a_q__mixed() {fxt.Test__hash("8215ef0796a20bcaaae116d3876c664a", "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq");}
@Test public void A_Z__a_z__0_9() {fxt.Test__hash("d174ab98d277d9f5a5611c2c9f419d9f", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");}
//@Test
@Test public void Empty() {fxt.Test__hash("d41d8cd98f00b204e9800998ecf8427e", "");}
@Test public void a() {fxt.Test__hash("0cc175b9c0f1b6a831c399e269772661", "a");}
@Test public void abc() {fxt.Test__hash("900150983cd24fb0d6963f7d28e17f72", "abc");}
@Test public void message_digest() {fxt.Test__hash("f96b697d7cb7938d525a2f31aaf161d0", "message digest");}
@Test public void a_z() {fxt.Test__hash("c3fcd3d76192e4007dfb496cca67e13b", "abcdefghijklmnopqrstuvwxyz");}
@Test public void a_q__mixed() {fxt.Test__hash("8215ef0796a20bcaaae116d3876c664a", "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq");}
@Test public void A_Z__a_z__0_9() {fxt.Test__hash("d174ab98d277d9f5a5611c2c9f419d9f", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");}
//@Test
public void Num__x_8() {fxt.Test__hash("57edf4a22be3c955ac49da2e2107b67a", String_.Repeat("1234567890", 8));}
//@Test
//@Test
public void A__x_1million() {fxt.Test__hash("7707d6ae4e027c70eea2a935c2296f21", String_.Repeat("a", 1000000));}
}

@ -1,29 +1,29 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.security.algos.jre; import gplx.*; import gplx.core.*; import gplx.core.security.*; import gplx.core.security.algos.*;
import org.junit.*;
public class Jre_hash_algo__sha1__tst { // REF: https://www.cosic.esat.kuleuven.be/nessie/testvectors/
private final Hash_algo__fxt fxt = new Hash_algo__fxt(Hash_algo_.New__sha1());
@Test public void Empty() {fxt.Test__hash("da39a3ee5e6b4b0d3255bfef95601890afd80709", "");}
@Test public void a() {fxt.Test__hash("86f7e437faa5a7fce15d1ddcb9eaeaea377667b8", "a");}
@Test public void abc() {fxt.Test__hash("a9993e364706816aba3e25717850c26c9cd0d89d", "abc");}
@Test public void message_digest() {fxt.Test__hash("c12252ceda8be8994d5fa0290a47231c1d16aae3", "message digest");}
@Test public void a_z() {fxt.Test__hash("32d10c7b8cf96570ca04ce37f2a19d84240d3a89", "abcdefghijklmnopqrstuvwxyz");}
@Test public void a_q__mixed() {fxt.Test__hash("84983e441c3bd26ebaae4aa1f95129e5e54670f1", "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq");}
@Test public void A_Z__a_z__0_9() {fxt.Test__hash("761c457bf73b14d27e9e9265c46f4b4dda11f940", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");}
@Test public void Empty() {fxt.Test__hash("da39a3ee5e6b4b0d3255bfef95601890afd80709", "");}
@Test public void a() {fxt.Test__hash("86f7e437faa5a7fce15d1ddcb9eaeaea377667b8", "a");}
@Test public void abc() {fxt.Test__hash("a9993e364706816aba3e25717850c26c9cd0d89d", "abc");}
@Test public void message_digest() {fxt.Test__hash("c12252ceda8be8994d5fa0290a47231c1d16aae3", "message digest");}
@Test public void a_z() {fxt.Test__hash("32d10c7b8cf96570ca04ce37f2a19d84240d3a89", "abcdefghijklmnopqrstuvwxyz");}
@Test public void a_q__mixed() {fxt.Test__hash("84983e441c3bd26ebaae4aa1f95129e5e54670f1", "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq");}
@Test public void A_Z__a_z__0_9() {fxt.Test__hash("761c457bf73b14d27e9e9265c46f4b4dda11f940", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");}
// @Test
public void Num() {fxt.Test__hash("50abf5706a150990a08b2c5ea40fa0e585554732", String_.Repeat("1234567890", 8));}
//@Test

@ -1,29 +1,29 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.security.algos.jre; import gplx.*; import gplx.core.*; import gplx.core.security.*; import gplx.core.security.algos.*;
import org.junit.*;
public class Jre_hash_algo__sha2_256__tst { // REF: https://www.cosic.esat.kuleuven.be/nessie/testvectors/
private final Hash_algo__fxt fxt = new Hash_algo__fxt(Hash_algo_.New__sha2_256());
@Test public void Empty() {fxt.Test__hash("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "");}
@Test public void a() {fxt.Test__hash("ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "a");}
@Test public void abc() {fxt.Test__hash("ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", "abc");}
@Test public void message_digest() {fxt.Test__hash("f7846f55cf23e14eebeab5b4e1550cad5b509e3348fbc4efa3a1413d393cb650", "message digest");}
@Test public void a_z() {fxt.Test__hash("71c480df93d6ae2f1efad1447c66c9525e316218cf51fc8d9ed832f2daf18b73", "abcdefghijklmnopqrstuvwxyz");}
@Test public void a_q__mixed() {fxt.Test__hash("248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1", "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq");}
@Test public void A_Z__a_z__0_9() {fxt.Test__hash("db4bfcbd4da0cd85a60c3c37d3fbd8805c77f15fc6b1fdfe614ee0a7c8fdb4c0", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");}
@Test public void Empty() {fxt.Test__hash("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "");}
@Test public void a() {fxt.Test__hash("ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "a");}
@Test public void abc() {fxt.Test__hash("ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", "abc");}
@Test public void message_digest() {fxt.Test__hash("f7846f55cf23e14eebeab5b4e1550cad5b509e3348fbc4efa3a1413d393cb650", "message digest");}
@Test public void a_z() {fxt.Test__hash("71c480df93d6ae2f1efad1447c66c9525e316218cf51fc8d9ed832f2daf18b73", "abcdefghijklmnopqrstuvwxyz");}
@Test public void a_q__mixed() {fxt.Test__hash("248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1", "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq");}
@Test public void A_Z__a_z__0_9() {fxt.Test__hash("db4bfcbd4da0cd85a60c3c37d3fbd8805c77f15fc6b1fdfe614ee0a7c8fdb4c0", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");}
// @Test
public void Num() {fxt.Test__hash("f371bc4a311f2b009eef952dd83ca80e2b60026c8e935592d0f9c308453c813e", String_.Repeat("1234567890", 8));}
//@Test

@ -1,22 +1,22 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.texts; import gplx.*; import gplx.core.*;
import org.junit.*;
public class BaseXXConverter_tst {
@Test public void Base32() {
@Test public void Base32() {
tst_Base32("", "");
tst_Base32("f", "MY");
tst_Base32("fo", "MZXQ");
@ -28,7 +28,7 @@ public class BaseXXConverter_tst {
tst_Base32("a", "ME");
tst_Base32("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", "IFBEGRCFIZDUQSKKJNGE2TSPKBIVEU2UKVLFOWCZLIZDGNBVGY3Q");
}
@Test public void Base64() {
@Test public void Base64() {
tst_Base64("", "");
tst_Base64("f", "Zg==");
tst_Base64("fo", "Zm8=");

@ -1,37 +1,37 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.texts; import gplx.*; import gplx.core.*;
import org.junit.*;
public class CharStream_tst {
@Before public void setup() {
stream = CharStream.pos0_("abcdefgh");
}
@Test public void To_str() {
@Test public void To_str() {
Tfds.Eq(stream.To_str(), "abcdefgh");
}
@Test public void CurrentText() {
@Test public void CurrentText() {
stream.MoveNextBy(1);
Tfds.Eq(stream.XtoStrAtCur(2), "bc");
Tfds.Eq(stream.To_str(), "abcdefgh");
}
@Test public void CurrentText_outOfBounds() {
@Test public void CurrentText_outOfBounds() {
stream.MoveNextBy(7);
Tfds.Eq(stream.XtoStrAtCur(2), "h");
}
@Test public void Match() {
@Test public void Match() {
stream.MoveNextBy(6);
tst_Match(true, "g");
tst_Match(false, "z");
@ -39,7 +39,7 @@ public class CharStream_tst {
tst_Match(false, "gz");
tst_Match(false, "ghi");
}
@Test public void AtBounds() {
@Test public void AtBounds() {
stream.Move_to(-1);
tst_AtBounds(true, false, false);

@ -1,50 +1,50 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.texts; import gplx.*; import gplx.core.*;
import org.junit.*;
public class RegxPatn_cls_ioMatch_tst {
@Test public void SimpleMatches() {
@Test public void SimpleMatches() {
tst_Matches("file.cs", "file.cs", true); // basic
tst_Matches("file.cs", "file.cs.exe", false); // fail: must match name precisely
tst_Matches("file.cs", "tst_file.cs", false); // fail: must match name precisely
}
@Test public void Wildcard() {
@Test public void Wildcard() {
tst_Matches("*.cs", "file.cs", true); // pass: before
tst_Matches("file*", "file_valid.cs", true); // pass: after
tst_Matches("*.exe", "file.cs", false); // fail: before
tst_Matches("file*", "invalid_file.cs", false); // fail: after
}
@Test public void DoubleWildcard() {
@Test public void DoubleWildcard() {
tst_Matches("*cs*", "file.cs", true); // pass: after
tst_Matches("*cs*", "csFile.exe", true); // pass: before
tst_Matches("*cs*", "file.cs.exe", true); // pass: middle
tst_Matches("*cs*", "file.exe", false); // fail
}
@Test public void Compound() {
@Test public void Compound() {
tst_Matches("*.cs|*.exe", "file.cs", true); // pass: match first
tst_Matches("*.cs|*.exe", "file.exe", true); // pass: match second
tst_Matches("*.cs|*.exe", "file.dll", false); // fail: match neither
tst_Matches("*.cs|*.exe", "file.cs.exe.dll", false); // fail: match neither (though both are embedded)
}
@Test public void Backslash() {
@Test public void Backslash() {
tst_Matches("*\\bin\\*", "C:\\project\\bin\\", true); // pass: dir
tst_Matches("*\\bin\\*", "C:\\project\\bin\\file.dll", true); // pass: fil
tst_Matches("*\\bin\\*", "C:\\project\\binFiles\\", false); // fail
}
@Test public void MixedCase() {
@Test public void MixedCase() {
tst_Matches("file.cs", "file.cs", true); // pass: same case
tst_Matches("file.cs", "File.cS", true); // pass: diff case
}

@ -1,28 +1,28 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.texts; import gplx.*; import gplx.core.*;
import org.junit.*; import gplx.langs.regxs.*;
public class RegxPatn_cls_like_tst {
@Test public void Basic() {
@Test public void Basic() {
tst_Match("abcd", "abcd", true); // basic; pass
tst_Match("abcd", "zbcd", false); // basic; fail
tst_Match("abcd", "abc", false); // no wildcard; must be exact match
tst_Match("a cd", "a cd", true); // check space works
}
@Test public void Wildcard() {
@Test public void Wildcard() {
tst_Match("abcd", "a%", true); // bgn; pass
tst_Match("abcd", "b%", false); // bgn; fail
tst_Match("abcd", "%d", true); // end; pass
@ -32,12 +32,12 @@ public class RegxPatn_cls_like_tst {
tst_Match("abcd", "%a%", true); // flank; bgn; pass
tst_Match("abcd", "%d%", true); // flank; end; pass
}
@Test public void Any() {
@Test public void Any() {
tst_Match("abcd", "a_cd", true); // basic; pass
tst_Match("abcd", "z_cd", false); // basic; fail
tst_Match("abcd", "a_c", false); // fail; check no wildcard
}
@Test public void CharSet() {
@Test public void CharSet() {
tst_Match("abcd", "a[b]cd", true); // pass
tst_Match("abcd", "a[x]cd", false); // fail
tst_Match("abcd", "a[bcde]cd", true); // multiple; pass
@ -45,20 +45,20 @@ public class RegxPatn_cls_like_tst {
tst_Match("abcd", "a[^z]cd", true); // not; pass
tst_Match("abcd", "a[^b]cd", false); // not; fail
}
@Test public void Escape() {
@Test public void Escape() {
tst_Match("a%b", "a|%b", true); // escape wildcard; pass
tst_Match("a%bc", "a|%b", false); // escape wildcard; fail
tst_Match("a|b", "a|b", false); // escape char; fail
tst_Match("a|b", "a||b", true); // escape char; pass
}
@Test public void Escape_diffChar() {
@Test public void Escape_diffChar() {
tst_Match("a%b", "a~%b", '~', true); // escape wildcard; pass
tst_Match("a%bc", "a~%b", '~', false); // escape wildcard; fail
tst_Match("a|b", "a|b", '~', true); // no escape needed
tst_Match("a~b", "a~b", '~', false); // escape char; fail
tst_Match("a~b", "a~~b", '~', true); // escape char; pass
}
@Test public void Chars() { // Escape Regx_bldr; ex: LIKE 'a{' -> a\{
@Test public void Chars() { // Escape Regx_bldr; ex: LIKE 'a{' -> a\{
tst_EscapeRegxChar(Regx_bldr.Tkn_Escape); // \
tst_EscapeRegxChar(Regx_bldr.Tkn_GroupBegin); // [
tst_EscapeRegxChar(Regx_bldr.Tkn_GroupEnd); // ]

@ -1,25 +1,25 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.texts; import gplx.*; import gplx.core.*;
import org.junit.*;
public class StringTableBldr_tst {
@Before public void setup() {
bldr = StringTableBldr.new_();
} StringTableBldr bldr;
@Test public void TwoCols() {
@Test public void TwoCols() {
bldr.Add("a", "aa")
.Add("bb", "b");
tst_XtoStr
@ -28,7 +28,7 @@ public class StringTableBldr_tst {
, ""
);
}
@Test public void RightAlign() {
@Test public void RightAlign() {
bldr.Add("a", "aa")
.Add("bb", "b");
bldr.FetchAtOrNew(0).Halign_(StringTableColAlign.Right);
@ -39,7 +39,7 @@ public class StringTableBldr_tst {
, ""
);
}
@Test public void CenterAlign() {
@Test public void CenterAlign() {
bldr.Add("aaaa", "a")
.Add("b", "bbbb");
bldr.FetchAtOrNew(0).Halign_(StringTableColAlign.Mid);

@ -1,36 +1,36 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.threads.poolables; import gplx.*; import gplx.core.*; import gplx.core.threads.*;
import org.junit.*;
public class Gfo_poolable_mgr_tst {
private final Gfo_poolable_mgr_tstr tstr = new Gfo_poolable_mgr_tstr();
@Before public void init() {tstr.Clear();}
@Test public void Get__one() {
@Test public void Get__one() {
tstr.Test__get(0);
tstr.Test__free__len(0);
tstr.Test__pool__len(2);
}
@Test public void Get__many__expand() {
@Test public void Get__many__expand() {
tstr.Test__get(0);
tstr.Test__get(1);
tstr.Test__get(2);
tstr.Test__free__len(0);
tstr.Test__pool__len(4);
}
@Test public void Rls__lifo() {
@Test public void Rls__lifo() {
tstr.Test__get(0);
tstr.Test__get(1);
tstr.Test__get(2);
@ -40,7 +40,7 @@ public class Gfo_poolable_mgr_tst {
tstr.Test__pool__nxt(0);
tstr.Test__free__len(0);
}
@Test public void Rls__fifo() {
@Test public void Rls__fifo() {
tstr.Test__get(0);
tstr.Test__get(1);
tstr.Test__get(2);

@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.times; import gplx.*; import gplx.core.*;
import org.junit.*;
public class DateAdp_parser_tst {
@Before public void init() {} DateAdp_parser_fxt fxt = new DateAdp_parser_fxt();
@Test public void Parse_gplx() {
@Test public void Parse_gplx() {
fxt.Test_Parse_iso8651_like("2000-01-02T03:04:05.006-05:00" , 2000, 1, 2, 3, 4, 5, 6);
fxt.Test_Parse_iso8651_like("2000-01-02" , 2000, 1, 2, 0, 0, 0, 0);
}

@ -1,66 +1,66 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.times; import gplx.*; import gplx.core.*;
import org.junit.*;
public class Time_span__basic_tst {
@Test public void seconds_() {
@Test public void seconds_() {
Time_span expd = Time_span_.fracs_(123987);
Time_span actl = Time_span_.seconds_(123.987);
Tfds.Eq(expd, actl);
}
@Test public void TotalSecs() {
@Test public void TotalSecs() {
Time_span val = Time_span_.fracs_(1987);
Tfds.Eq_decimal(Decimal_adp_.parts_(1, 987), val.Total_secs());
}
@Test public void Units() {
@Test public void Units() {
tst_Units("01:02:03.987", 1, 2, 3, 987);
tst_Units("01:00:03", 1, 0, 3, 0);
tst_Units("01:00:00.987", 1, 0, 0, 987);
tst_Units("02:00.987", 0, 2, 0, 987);
}
@Test public void Add() {
@Test public void Add() {
Time_span val = Time_span_.fracs_(3);
Time_span arg = Time_span_.fracs_(2);
Time_span expd = Time_span_.fracs_(5);
Time_span actl = val.Add(arg);
Tfds.Eq(expd, actl);
}
@Test public void Subtract() {
@Test public void Subtract() {
Time_span val = Time_span_.fracs_(3);
Time_span arg = Time_span_.fracs_(2);
Time_span expd = Time_span_.fracs_(1);
Time_span actl = val.Subtract(arg);
Tfds.Eq(expd, actl);
}
@Test public void Add_unit_identity() {
@Test public void Add_unit_identity() {
tst_AddUnit("00:00:01.000", 0, 0, "00:00:01.000");
}
@Test public void Add_unit_basic() {
@Test public void Add_unit_basic() {
tst_AddUnit("01:59:58.987", 0, 1013, "02:00:00.000");
tst_AddUnit("01:59:58.987", 1, 2, "02:00:00.987");
tst_AddUnit("01:59:58.987", 2, 1, "02:00:58.987");
tst_AddUnit("01:59:58.987", 3, 1, "02:59:58.987");
}
@Test public void Add_unit_negative() {
@Test public void Add_unit_negative() {
tst_AddUnit("01:00:00.00", 0, -1, "00:59:59.999");
tst_AddUnit("01:00:00.00", 1, -1, "00:59:59.000");
tst_AddUnit("01:00:00.00", 2, -1, "00:59:00.000");
tst_AddUnit("01:00:00.00", 3, -1, "00:00:00.000");
}
@Test public void XtoStrUiAbbrv() {
@Test public void XtoStrUiAbbrv() {
tst_XtoStrUiAbbrv("01:02:03.004", "1h 2m 3s 4f");
tst_XtoStrUiAbbrv("00:00:03.004", "3s 4f");
tst_XtoStrUiAbbrv("00:00:03.000", "3s 0f");

@ -1,45 +1,45 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.times; import gplx.*; import gplx.core.*;
import org.junit.*;
public class Time_span__parse_tst {
@Test public void Zero() {
@Test public void Zero() {
tst_Parse("0", 0);
}
@Test public void Milliseconds() {
@Test public void Milliseconds() {
tst_Parse("0.987", 987);
tst_Parse("0.00199", 1); // do not parse as 199
tst_Parse("0.1", 100); // do not parse as 1
}
@Test public void Seconds() {
@Test public void Seconds() {
tst_Parse("1.987", 1987);
}
@Test public void Minutes() {
@Test public void Minutes() {
tst_Parse("1:02.987", 62987);
}
@Test public void MinuteSecondOnly() {
@Test public void MinuteSecondOnly() {
tst_Parse("1:02", 62000);
}
@Test public void Hour() {
@Test public void Hour() {
tst_Parse("1:02:03.987", 3723987);
}
@Test public void Negative() {
@Test public void Negative() {
tst_Parse("-1:02:03.987", -3723987);
}
@Test public void Loopholes() {
@Test public void Loopholes() {
tst_Parse("001:02", 62000); // multiple leading zeroes
tst_Parse("1.2.3.4", 1200); // ignore all decimals except first
tst_Parse("60:60.9999", 3660999); // value does not need to be bounded to limits (except fracs, which is always < 1000)

@ -1,43 +1,43 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.times; import gplx.*; import gplx.core.*;
import org.junit.*;
public class Time_span__to_str_tst {
@Test public void Zero() {
@Test public void Zero() {
tst_Default(0, "0");
}
@Test public void MinuteSeconds() {
@Test public void MinuteSeconds() {
tst_Default(77000, "1:17");
}
@Test public void ZeroSuppression() {
@Test public void ZeroSuppression() {
tst_Default(660000, "11:00"); //fractional 0 and leading 0s are suppressed; i.e.: not 00:11:00.000
}
@Test public void HourTest() {
@Test public void HourTest() {
tst_Default(3723987, "1:02:03.987");
}
@Test public void NegSeconds() {
@Test public void NegSeconds() {
tst_Default(-2000, "-2");
}
@Test public void NegMins() {
@Test public void NegMins() {
tst_Default(-60000, "-1:00");
}
@Test public void NegHours() {
@Test public void NegHours() {
tst_Default(-3723981, "-1:02:03.981");
}
@Test public void ZeroPadding() {
@Test public void ZeroPadding() {
tst_ZeroPadding("0", "00:00:00.000");
tst_ZeroPadding("1:02:03.123", "01:02:03.123");
tst_ZeroPadding("1", "00:00:01.000");

@ -13,14 +13,14 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.type_xtns; import gplx.*; import gplx.core.*;
import org.junit.*;
public class DateAdpClassXtn_tst {
@Test public void XtoDb() {
tst_XtoDb("20091115 220102.999", "2009-11-15 22:01:02.999");
}
void tst_XtoDb(String val, String expdRaw) {
String actlRaw = (String)DateAdpClassXtn.Instance.XtoDb(DateAdp_.parse_gplx(val));
Tfds.Eq(expdRaw, actlRaw);
}
}
package gplx.core.type_xtns; import gplx.*; import gplx.core.*;
import org.junit.*;
public class DateAdpClassXtn_tst {
@Test public void XtoDb() {
tst_XtoDb("20091115 220102.999", "2009-11-15 22:01:02.999");
}
void tst_XtoDb(String val, String expdRaw) {
String actlRaw = (String)DateAdpClassXtn.Instance.XtoDb(DateAdp_.parse_gplx(val));
Tfds.Eq(expdRaw, actlRaw);
}
}

@ -1,39 +1,39 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.dsvs; import gplx.*; import gplx.langs.*;
import org.junit.*; import gplx.core.strings.*; import gplx.core.gfo_ndes.*;
public class DsvDataRdr_csv_dat_tst {
public class DsvDataRdr_csv_dat_tst {
@Before public void setup() {
fx.Parser_(DsvParser.csv_(false, GfoFldList_.Null));
fx.Clear();
} DsvDataRdr_fxt fx = DsvDataRdr_fxt.new_();
@Test public void Empty() {
@Test public void Empty() {
fx.run_parse_("");
fx.tst_DatNull();
}
@Test public void Fld_0() {
@Test public void Fld_0() {
fx.run_parse_("a");
fx.tst_DatCsv(fx.ary_("a"));
}
@Test public void Fld_N() {
@Test public void Fld_N() {
fx.run_parse_("a,b,c");
fx.tst_FldListCsv("fld0", "fld1", "fld2");
fx.tst_DatCsv(fx.ary_("a", "b", "c"));
}
@Test public void Row_N() {
@Test public void Row_N() {
fx.run_parse_
( "a,b,c", String_.CrLf
, "1,2,3"
@ -43,43 +43,43 @@ public class DsvDataRdr_csv_dat_tst {
, fx.ary_("1", "2", "3")
);
}
@Test public void Escape_WhiteSpace() {
@Test public void Escape_WhiteSpace() {
fx.run_parse_("a,\" \t\",c");
fx.tst_DatCsv(fx.ary_("a", " \t", "c"));
}
@Test public void Escape_FldSep() {
@Test public void Escape_FldSep() {
fx.run_parse_("a,\",\",c");
fx.tst_DatCsv(fx.ary_("a", ",", "c"));
}
@Test public void Escape_RowSep() {
@Test public void Escape_RowSep() {
fx.run_parse_("a,\"" + String_.CrLf + "\",c");
fx.tst_DatCsv(fx.ary_("a", String_.CrLf, "c"));
}
@Test public void Escape_Quote() {
@Test public void Escape_Quote() {
fx.run_parse_("a,\"\"\"\",c");
fx.tst_DatCsv(fx.ary_("a", "\"", "c"));
}
@Test public void Blank_Null() {
@Test public void Blank_Null() {
fx.run_parse_("a,,c");
fx.tst_DatCsv(fx.ary_("a", null, "c"));
}
@Test public void Blank_EmptyString() {
@Test public void Blank_EmptyString() {
fx.run_parse_("a,\"\",c");
fx.tst_DatCsv(fx.ary_("a", "", "c"));
}
@Test public void Blank_Null_Multiple() {
@Test public void Blank_Null_Multiple() {
fx.run_parse_(",,");
fx.tst_DatCsv(fx.ary_(null, null, null));
}
@Test public void TrailingNull() {
@Test public void TrailingNull() {
fx.run_parse_("a,");
fx.tst_DatCsv(fx.ary_("a", null));
}
@Test public void TrailingEmpty() {
@Test public void TrailingEmpty() {
fx.run_parse_("a,\"\"");
fx.tst_DatCsv(fx.ary_("a", ""));
}
@Test public void Quote_Error() {
@Test public void Quote_Error() {
try {
fx.run_parse_("a,\"\" ,c");
Tfds.Fail_expdError();
@ -88,7 +88,7 @@ public class DsvDataRdr_csv_dat_tst {
Tfds.Eq_true(String_.Has(Err_.Message_lang(e), "invalid quote in quoted field"));
}
}
@Test public void Misc_AllowValsLessThanFields() {
@Test public void Misc_AllowValsLessThanFields() {
// assume null when vals.Count < fields.Count; PURPOSE: MsExcel will not save trailing commas for csvExport; ex: a, -> a
fx.run_parse_
( "a0,a1", String_.CrLf
@ -99,7 +99,7 @@ public class DsvDataRdr_csv_dat_tst {
, fx.ary_("b0", null)
);
}
@Test public void Misc_NewLineValidForSingleColumnTables() {
@Test public void Misc_NewLineValidForSingleColumnTables() {
fx.run_parse_
( "a", String_.CrLf
, String_.CrLf
@ -113,7 +113,7 @@ public class DsvDataRdr_csv_dat_tst {
, fx.ary_null_()
);
}
@Test public void Misc_NewLineValidForSingleColumnTables_FirstLine() {
@Test public void Misc_NewLineValidForSingleColumnTables_FirstLine() {
fx.run_parse_
( String_.CrLf
, "b", String_.CrLf
@ -125,7 +125,7 @@ public class DsvDataRdr_csv_dat_tst {
, fx.ary_("c")
);
}
@Test public void Hdr_Basic() {
@Test public void Hdr_Basic() {
fx.Parser_(DsvParser.csv_(true, GfoFldList_.Null));
fx.run_parse_
( "id,name", String_.CrLf
@ -134,7 +134,7 @@ public class DsvDataRdr_csv_dat_tst {
fx.tst_FldListCsv("id", "name");
fx.tst_DatCsv(fx.ary_("0", "me"));
}
// @Test public void Hdr_Manual() {
// @Test public void Hdr_Manual() {
// fx.Parser_(DsvParser.csv_(false, GfoFldList_.new_().Add("id", IntClassXtn.Instance).Add("name", StringClassXtn.Instance), true));
// fx.run_parse_("0,me");
// fx.tst_DatCsv(fx.ary_(0, "me")); // NOTE: testing auto-parsing of id to int b/c id fld is IntClassXtn.Instance;

@ -1,28 +1,28 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.dsvs; import gplx.*; import gplx.langs.*;
import org.junit.*;
public class DsvDataRdr_dsv_dat_tst {
public class DsvDataRdr_dsv_dat_tst {
@Before public void setup() {fx.Clear();} DsvDataRdr_fxt fx = DsvDataRdr_fxt.new_();
@Test public void NameOnly() {
@Test public void NameOnly() {
fx.run_parse_("tableName, ,\" \",#");
fx.tst_Tbls("tableName");
fx.tst_Dat(0);
}
@Test public void Rows_N() {
@Test public void Rows_N() {
fx.run_parse_lines_
( "numbers, ,\" \",#"
, "1,2,3"
@ -34,7 +34,7 @@ public class DsvDataRdr_dsv_dat_tst {
, fx.ary_("4", "5", "6")
);
}
@Test public void Tbls_N() {
@Test public void Tbls_N() {
fx.run_parse_lines_
( "letters, ,\" \",#"
, "a,b,c"
@ -46,7 +46,7 @@ public class DsvDataRdr_dsv_dat_tst {
fx.tst_Dat(0, fx.ary_("a", "b", "c"));
fx.tst_Dat(1, fx.ary_("1", "2", "3"), fx.ary_("4", "5", "6"));
}
@Test public void IgnoreTrailingBlankRow() {
@Test public void IgnoreTrailingBlankRow() {
fx.run_parse_lines_
( "letters, ,\" \",#"
, "a,b,c"
@ -55,7 +55,7 @@ public class DsvDataRdr_dsv_dat_tst {
fx.tst_Tbls("letters");
fx.tst_Dat(0, fx.ary_("a", "b", "c"));
}
@Test public void AllowCommentsDuringData() {
@Test public void AllowCommentsDuringData() {
fx.run_parse_lines_
( "letters, ,\" \",#"
, "a,b,c"

@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.dsvs; import gplx.*; import gplx.langs.*;
import org.junit.*; import gplx.core.gfo_ndes.*; import gplx.core.type_xtns.*;
public class DsvDataRdr_dsv_hdr_tst {
public class DsvDataRdr_dsv_hdr_tst {
@Before public void setup() {fx.Clear();} DsvDataRdr_fxt fx = DsvDataRdr_fxt.new_();
@Test public void Names() {
@Test public void Names() {
fx.run_parse_lines_
( "id,name, ,\" \",@"
, "0,me"
@ -30,7 +30,7 @@ public class DsvDataRdr_dsv_hdr_tst {
, fx.ary_("1", "you")
);
}
@Test public void Types() {
@Test public void Types() {
fx.run_parse_lines_
( "int," + StringClassXtn.Key_const + ", ,\" \",$"
, "0,me"
@ -42,7 +42,7 @@ public class DsvDataRdr_dsv_hdr_tst {
, fx.ary_(1, "you")
);
}
@Test public void NamesAndTypes() {
@Test public void NamesAndTypes() {
fx.run_parse_lines_
( "id,name, ,\" \",@"
, "int," + StringClassXtn.Key_const + ", ,\" \",$"
@ -55,7 +55,7 @@ public class DsvDataRdr_dsv_hdr_tst {
, fx.ary_(1, "you")
);
}
@Test public void MultipleTables_NoData() {
@Test public void MultipleTables_NoData() {
fx.run_parse_lines_
( "persons, ,\" \",#"
, "id,name, ,\" \",@"
@ -68,7 +68,7 @@ public class DsvDataRdr_dsv_hdr_tst {
fx.tst_Dat(0);
fx.tst_Dat(1);
}
@Test public void Comment() {
@Test public void Comment() {
fx.run_parse_lines_
( "--------------------, ,\" \",//"
, "tbl0, ,\" \",#"

@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.dsvs; import gplx.*; import gplx.langs.*;
import org.junit.*; import gplx.core.gfo_ndes.*; import gplx.core.type_xtns.*;
public class DsvDataRdr_dsv_misc_tst {
public class DsvDataRdr_dsv_misc_tst {
@Before public void setup() {fx.Clear();} DsvDataRdr_fxt fx = DsvDataRdr_fxt.new_();
@Test public void CmdDlm_NearMatches() {
@Test public void CmdDlm_NearMatches() {
fx.run_parse_("a, ,b");
fx.tst_DatCsv(fx.ary_("a", " ", "b"));
fx.Clear();
@ -30,7 +30,7 @@ public class DsvDataRdr_dsv_misc_tst {
fx.tst_DatCsv(fx.ary_("a", " ", "b", " ", "c"));
fx.Clear();
}
@Test public void CmdDlm_DoNotSpanLines() {
@Test public void CmdDlm_DoNotSpanLines() {
fx.run_parse_lines_
( "a, "
, "\" \",b"
@ -40,11 +40,11 @@ public class DsvDataRdr_dsv_misc_tst {
, fx.ary_(" ", "b")
);
}
@Test public void CmdDlm_SecondFldMustBeQuoted() {
@Test public void CmdDlm_SecondFldMustBeQuoted() {
fx.run_parse_lines_("a, , ,b"); // will fail with "invalid command: b", if second , , is interpreted as command delimiter
fx.tst_DatCsv(fx.ary_("a", " ", " ", "b"));
}
@Test public void Null_Int() {
@Test public void Null_Int() {
fx.run_parse_ // not using run_parse_lines_ b/c (a) will have extra lineBreak; (b) test will look funny;
( "int," + StringClassXtn.Key_const + ", ,\" \",$", String_.CrLf
, ",val1"
@ -53,7 +53,7 @@ public class DsvDataRdr_dsv_misc_tst {
fx.tst_Flds(0, GfoFldList_.new_().Add("fld0", IntClassXtn.Instance).Add("fld1", StringClassXtn.Instance));
fx.tst_Dat(0, fx.ary_(null, "val1"));
}
@Test public void Null_String() {
@Test public void Null_String() {
fx.run_parse_ // not using run_parse_lines_ b/c (a) will have extra lineBreak; (b) test will look funny;
( StringClassXtn.Key_const + "," + StringClassXtn.Key_const + ", ,\" \",$", String_.CrLf
, ",val1"
@ -62,7 +62,7 @@ public class DsvDataRdr_dsv_misc_tst {
fx.tst_Flds(0, GfoFldList_.new_().Add("fld0", StringClassXtn.Instance).Add("fld1", StringClassXtn.Instance));
fx.tst_Dat(0, fx.ary_(null, "val1"));
}
@Test public void EmptyString() {
@Test public void EmptyString() {
fx.run_parse_ // not using run_parse_lines_ b/c (a) will have extra lineBreak; (b) test will look funny;
( StringClassXtn.Key_const + "," + StringClassXtn.Key_const + ", ,\" \",$", String_.CrLf
, "\"\",val1"

@ -1,42 +1,42 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.dsvs; import gplx.*; import gplx.langs.*;
import org.junit.*; import gplx.core.gfo_ndes.*; import gplx.core.type_xtns.*;
public class DsvDataRdr_layout_tst {
@Test public void TableName() {
public class DsvDataRdr_layout_tst {
@Test public void TableName() {
run_parse_lines("table0, ,\" \",#");
tst_Layout(0, DsvHeaderItm.Id_TableName);
}
@Test public void Comment() {
@Test public void Comment() {
run_parse_lines("-------------, ,\" \",//", "data"); // need dataLine or parser will throw away standalone header
tst_Layout(0, DsvHeaderItm.Id_Comment);
}
@Test public void BlankLine() {
@Test public void BlankLine() {
run_parse_lines("", "data"); // need dataLine or parser will throw away standalone header
tst_Layout(0, DsvHeaderItm.Id_BlankLine);
}
@Test public void LeafNames() {
@Test public void LeafNames() {
run_parse_lines("id,name, ,\" \",@");
tst_Layout(0, DsvHeaderItm.Id_LeafNames);
}
@Test public void LeafTypes() {
@Test public void LeafTypes() {
run_parse_lines("int," + StringClassXtn.Key_const + ", ,\" \",$");
tst_Layout(0, DsvHeaderItm.Id_LeafTypes);
}
@Test public void Combined() {
@Test public void Combined() {
run_parse_lines
( ""
, "-------------, ,\" \",//"
@ -55,7 +55,7 @@ public class DsvDataRdr_layout_tst {
, DsvHeaderItm.Id_Comment
);
}
@Test public void Tbl_N() {
@Test public void Tbl_N() {
run_parse_lines
( ""
, "*************, ,\" \",//"
@ -83,7 +83,7 @@ public class DsvDataRdr_layout_tst {
, DsvHeaderItm.Id_Comment
);
}
@Test public void Tbl_N_FirstIsEmpty() {
@Test public void Tbl_N_FirstIsEmpty() {
run_parse_lines
( ""
, "*************, ,\" \",//"

@ -1,37 +1,37 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.dsvs; import gplx.*; import gplx.langs.*;
import org.junit.*; import gplx.core.gfo_ndes.*; import gplx.core.type_xtns.*;
public class DsvDataWtr_csv_tst {
@Test public void Dat_Val_0() {
@Test public void Dat_Val_0() {
root = fx_nde.csv_dat_(); this.AddCsvRow(root);
expd = String_.Concat_lines_crlf("");
fx.tst_XtoStr(wtr, root, expd);
}
@Test public void Dat_Val_1() {
@Test public void Dat_Val_1() {
root = fx_nde.csv_dat_(); this.AddCsvRow(root, "a");
expd = String_.Concat_lines_crlf("a");
fx.tst_XtoStr(wtr, root, expd);
}
@Test public void Dat_Val_N() {
@Test public void Dat_Val_N() {
root = fx_nde.csv_dat_(); this.AddCsvRow(root, "a", "b", "c");
expd = String_.Concat_lines_crlf("a,b,c");
fx.tst_XtoStr(wtr, root, expd);
}
@Test public void Dat_Row_N() {
@Test public void Dat_Row_N() {
root = fx_nde.csv_dat_();
this.AddCsvRow(root, "a", "b", "c");
this.AddCsvRow(root, "d", "e", "f");
@ -41,37 +41,37 @@ public class DsvDataWtr_csv_tst {
);
fx.tst_XtoStr(wtr, root, expd);
}
@Test public void Dat_Escape_FldSpr() { // ,
@Test public void Dat_Escape_FldSpr() { // ,
root = fx_nde.csv_dat_(); this.AddCsvRow(root, "a", ",", "c");
expd = String_.Concat_lines_crlf("a,\",\",c");
fx.tst_XtoStr(wtr, root, expd);
}
@Test public void Dat_Escape_RcdSpr() { // NewLine
@Test public void Dat_Escape_RcdSpr() { // NewLine
root = fx_nde.csv_dat_(); this.AddCsvRow(root, "a", String_.CrLf, "c");
expd = String_.Concat_lines_crlf("a,\"" + String_.CrLf + "\",c");
fx.tst_XtoStr(wtr, root, expd);
}
@Test public void Dat_Escape_Quote() { // " -> ""
@Test public void Dat_Escape_Quote() { // " -> ""
root = fx_nde.csv_dat_(); this.AddCsvRow(root, "a", "\"", "c");
expd = String_.Concat_lines_crlf("a,\"\"\"\",c");
fx.tst_XtoStr(wtr, root, expd);
}
@Test public void Dat_Whitespace() {
@Test public void Dat_Whitespace() {
root = fx_nde.csv_dat_(); this.AddCsvRow(root, "a", " b\t", "c");
expd = String_.Concat_lines_crlf("a, b\t,c");
fx.tst_XtoStr(wtr, root, expd);
}
@Test public void Dat_Null() {
@Test public void Dat_Null() {
root = fx_nde.csv_dat_(); this.AddCsvRow(root, "a", null, "c");
expd = String_.Concat_lines_crlf("a,,c");
fx.tst_XtoStr(wtr, root, expd);
}
@Test public void Dat_EmptyString() {
@Test public void Dat_EmptyString() {
root = fx_nde.csv_dat_(); this.AddCsvRow(root, "a", "", "c");
expd = String_.Concat_lines_crlf("a,\"\",c");
fx.tst_XtoStr(wtr, root, expd);
}
@Test public void Hdr_Flds() {
@Test public void Hdr_Flds() {
wtr = DsvDataWtr_.csv_hdr_();
GfoFldList flds = GfoFldList_.new_().Add("id", StringClassXtn.Instance).Add("name", StringClassXtn.Instance);
root = fx_nde.csv_hdr_(flds); this.AddCsvRow(root, "0", "me");

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.dsvs; import gplx.*; import gplx.langs.*;
import org.junit.*; import gplx.core.gfo_ndes.*;
public class DsvDataWtr_tbls_tst {
@ -21,12 +21,12 @@ public class DsvDataWtr_tbls_tst {
layout.HeaderList().Add_TableName();
wtr.InitWtr(DsvStoreLayout.Key_const, layout);
}
@Test public void Rows_0() {
@Test public void Rows_0() {
root = fx_nde.tbl_("tbl0");
expd = String_.Concat_lines_crlf( "tbl0, ,\" \",#");
fx.tst_XtoStr(wtr, root, expd);
}
@Test public void Rows_N() {
@Test public void Rows_N() {
root = fx_nde.tbl_
( "numbers"
, fx_nde.row_vals_(1, 2, 3)
@ -39,7 +39,7 @@ public class DsvDataWtr_tbls_tst {
);
fx.tst_XtoStr(wtr, root, expd);
}
@Test public void Tbls_N_Empty() {
@Test public void Tbls_N_Empty() {
root = fx_nde.root_
( fx_nde.tbl_("tbl0")
, fx_nde.tbl_("tbl1")
@ -50,7 +50,7 @@ public class DsvDataWtr_tbls_tst {
);
fx.tst_XtoStr(wtr, root, expd);
}
@Test public void Tbls_N() {
@Test public void Tbls_N() {
root = fx_nde.root_
( fx_nde.tbl_("letters"
, fx_nde.row_vals_("a", "b", "c"))

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.gfs; import gplx.*; import gplx.langs.*;
import gplx.core.gfo_regys.*;
public class GfsCore implements Gfo_invk {

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save