1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2014-08-03 23:31:22 -04:00
parent 7b6e65b088
commit fb8c06c560
191 changed files with 1869 additions and 722 deletions

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx;
import org.junit.*;
public class ErrProcData_tst {
@Test public void parse_() {
@Test public void parse_() {
tst_parse_("gplx._tst.Err__tst.RdrLoad(MethodData_tst.java:1)"
, ErrProcData.new_()
.SignatureRaw_("gplx._tst.Err__tst.RdrLoad")
@@ -27,7 +27,7 @@ public class ErrProcData_tst {
.IdeAddress_("(MethodData_tst.java:1)")
);
}
@Test public void parse_ary_() {
@Test public void parse_ary_() {
String stackTrace = "";
try {ThrowException();} catch (Exception exc) {stackTrace = Err_.StackTrace_lang(exc);}
ErrProcData[] ary = ErrProcData.parse_ary_(stackTrace);

View File

@@ -66,6 +66,12 @@ public class Err_ { //_20110415
public static String Message_lang(Exception e) {return e.getClass() + " " + e.getMessage();}
public static String Message_gplx(Exception e) {return ErrMsgWtr._.Message_gplx(e);}
public static String Message_gplx_brief(Exception e) {return ErrMsgWtr._.Message_gplx_brief(e);}
public static String Message_hdr_or_message(Exception e) {
if (e == null) return "exception is null";
return ClassAdp_.Eq(e.getClass(), Err.class)
? ((Err)e).Hdr()
: Message_lang(e);
}
@gplx.Internal protected static String StackTrace_lang(Exception e) {
String_bldr sb = String_bldr_.new_();
StackTraceElement[] stackTraceAry = e.getStackTrace();

View File

@@ -18,19 +18,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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));

View File

@@ -212,7 +212,8 @@ public class Bry_ {
}
public static byte[] Mid_by_len(byte[] src, int bgn, int len) {return Mid(src, bgn, bgn + len);}
public static byte[] Mid_by_len_safe(byte[] src, int bgn, int len) {
if (len > src.length) len = src.length;
int src_len = src.length;
if (len + bgn > src_len) len = (src_len - bgn);
return Mid(src, bgn, bgn + len);
}
public static String MidByLenToStr(byte[] src, int bgn, int len) {

View File

@@ -123,6 +123,7 @@ public class Bry_bfr {
public Bry_bfr Add_byte_pipe() {return Add_byte(Byte_ascii.Pipe);}
public Bry_bfr Add_byte_comma() {return Add_byte(Byte_ascii.Comma);}
public Bry_bfr Add_byte_apos() {return Add_byte(Byte_ascii.Apos);}
public Bry_bfr Add_byte_slash() {return Add_byte(Byte_ascii.Slash);}
public Bry_bfr Add_byte_backslash() {return Add_byte(Byte_ascii.Backslash);}
public Bry_bfr Add_byte_quote() {return Add_byte(Byte_ascii.Quote);}
public Bry_bfr Add_byte_space() {return Add_byte(Byte_ascii.Space);}

View File

@@ -18,14 +18,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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_.int_(v));} // WORKAROUND/JAVA: expd is of type int b/c java promotes numbers to ints
@Test public void XtoInt() {
@Test public void XtoInt() {
tst_XtoInt( 0, 0);
tst_XtoInt( 127, 127);
tst_XtoInt( 128, 128);

View File

@@ -70,8 +70,10 @@ public class Byte_ascii {
;
}
public static final byte[]
Dot_bry = new byte[] {Byte_ascii.Dot}
Tab_bry = new byte[] {Byte_ascii.Tab}
, NewLine_bry = new byte[] {Byte_ascii.NewLine}
, Dot_bry = new byte[] {Byte_ascii.Dot}
, Comma_bry = new byte[] {Byte_ascii.Comma}
, Colon_bry = new byte[] {Byte_ascii.Colon}
, Lt_bry = new byte[] {Byte_ascii.Lt}
, Gt_bry = new byte[] {Byte_ascii.Gt}

View File

@@ -39,7 +39,7 @@ public class Double_ {
int v_as_int = (int)v;
return v == v_as_int
? Int_.XtoStr(v_as_int) // convert to int, and call print String to eliminate any trailing decimal places
: String.format("%g", v); // call "%g" format which should eliminate most, though not all; EX:2449.6000000000004; DATE:2014-07-14
: Float_.XtoStr((float)v); // calling ((float)v).toString is better at removing trailing 0s than String.format("%g", v). note that .net .toString() handles it better; EX:2449.600000000000d; DATE:2014-07-29
}
public static double cast_(Object o) {try {return (Double)o;} catch(Exception e) {throw Err_.type_mismatch_exc_(e, double.class, o);}}
public static double parse_(String raw) {try {return Double.parseDouble(raw);} catch(Exception e) {throw Err_.parse_type_exc_(e, double.class, raw);}}

View File

@@ -0,0 +1,29 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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_.Xto_str_loose(v));}
}

View File

@@ -27,7 +27,7 @@ public class Object__tst {
}
@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.60");
fxt.Test_xto_str_loose_or_null(2449.6000000000004d, "2449.6");
}
}
class Object__fxt {

View File

@@ -18,12 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx;
import org.junit.*;
public class KeyValHash_tst {
@Test public void AryVals() {
@Test public void AryVals() {
tst_AryVals(ary_());
tst_AryVals(ary_("key1", "1"), kv_("key1", "1"));
tst_AryVals(ary_("key1", "1", "key2", "2"), kv_("key1", "1"), kv_("key2", "2"));
}
@Test public void Fail_lengthMustBeEven() {
@Test public void Fail_lengthMustBeEven() {
try {
tst_AryVals(ary_("key1"), kv_("key1", "1"));
Tfds.Fail_expdError();

View File

@@ -18,51 +18,51 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx;
import org.junit.*;
public class TimeSpanAdp_basic_tst {
@Test public void seconds_() {
@Test public void seconds_() {
TimeSpanAdp expd = TimeSpanAdp_.fracs_(123987);
TimeSpanAdp actl = TimeSpanAdp_.seconds_(123.987);
Tfds.Eq(expd, actl);
}
@Test public void TotalSecs() {
@Test public void TotalSecs() {
TimeSpanAdp val = TimeSpanAdp_.fracs_(1987);
Tfds.Eq_decimal(DecimalAdp_.parts_(1, 987), val.TotalSecs());
}
@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() {
TimeSpanAdp val = TimeSpanAdp_.fracs_(3);
TimeSpanAdp arg = TimeSpanAdp_.fracs_(2);
TimeSpanAdp expd = TimeSpanAdp_.fracs_(5);
TimeSpanAdp actl = val.Add(arg);
Tfds.Eq(expd, actl);
}
@Test public void Subtract() {
@Test public void Subtract() {
TimeSpanAdp val = TimeSpanAdp_.fracs_(3);
TimeSpanAdp arg = TimeSpanAdp_.fracs_(2);
TimeSpanAdp expd = TimeSpanAdp_.fracs_(1);
TimeSpanAdp 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");

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx;
import org.junit.*;
public class UuidAdp__tst {
@Test public void parse_() {
@Test public void parse_() {
tst_parse_("467ffb41-cdfe-402f-b22b-be855425784b");
}
void tst_parse_(String s) {

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.criterias; import gplx.*;
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);
@@ -28,7 +28,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);
@@ -38,7 +38,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);
@@ -49,21 +49,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);
@@ -72,7 +72,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);

View File

@@ -18,12 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx;
import org.junit.*;
public class ListAdp_Sorter_tst {
@Test public void Basic() {
@Test public void Basic() {
Object[] src = new Object[] {0,8,1,7,2,6,3,5,4};
ListAdp_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"};
ListAdp_Sorter.new_().Sort(src, src.length);
Tfds.Eq_ary(src, new Object[] {"0","1","2","3","4","5","6","7","8"});

View File

@@ -21,11 +21,11 @@ public class OrderedHash_tst {
@Before public void setup() {
hash = OrderedHash_.new_();
}
@Test public void FetchAt() {
@Test public void FetchAt() {
hash.Add("key1", "val1");
Tfds.Eq("val1", hash.FetchAt(0));
}
@Test public void iterator() {
@Test public void iterator() {
hash.Add("key2", "val2");
hash.Add("key1", "val1");

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.lists; import gplx.*;
import org.junit.*;
public class StackAdp_tst {
@Test public void XtoList() {
@Test public void XtoList() {
tst_XtoList(1, 2, 3);
}
void tst_XtoList(int... ary) {

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.texts; import gplx.*;
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");
@@ -30,7 +30,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=");

View File

@@ -21,19 +21,19 @@ public class CharStream_tst {
@Before public void setup() {
stream = CharStream.pos0_("abcdefgh");
}
@Test public void XtoStr() {
@Test public void XtoStr() {
Tfds.Eq(stream.XtoStr(), "abcdefgh");
}
@Test public void CurrentText() {
@Test public void CurrentText() {
stream.MoveNextBy(1);
Tfds.Eq(stream.XtoStrAtCur(2), "bc");
Tfds.Eq(stream.XtoStr(), "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");
@@ -41,7 +41,7 @@ public class CharStream_tst {
tst_Match(false, "gz");
tst_Match(false, "ghi");
}
@Test public void AtBounds() {
@Test public void AtBounds() {
stream.MoveTo(-1);
tst_AtBounds(true, false, false);

View File

@@ -18,35 +18,35 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.texts; import gplx.*;
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
}

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.security; import gplx.*;
import org.junit.*;
public class HashAlgo_tth192_tree_tst {
@Test public void CalcRecursiveHalves() {
@Test public void CalcRecursiveHalves() {
tst_CalcRecursiveHalves(129, 128);
tst_CalcRecursiveHalves(128, 127);
tst_CalcRecursiveHalves(100, 99);
@@ -31,7 +31,7 @@ public class HashAlgo_tth192_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)

View File

@@ -392,8 +392,10 @@ public class IoEngine_system extends IoEngine_base {
Io_download_fmt xfer_fmt = xrg.Download_fmt();
prog_dlg = xfer_fmt.usr_dlg;
if (!Web_access_enabled) {
if (session_fil == null) session_fil = prog_dlg.Log_wtr().Session_dir().GenSubFil("internet.txt");
if (prog_dlg != null) prog_dlg.Log_wtr().Log_msg_to_url_fmt(session_fil, "download disabled: src='~{0}' trg='~{1}'", xrg.Src(), xrg.Trg().Raw());
if (prog_dlg != null) {
if (session_fil == null) session_fil = prog_dlg.Log_wtr().Session_dir().GenSubFil("internet.txt");
prog_dlg.Log_wtr().Log_msg_to_url_fmt(session_fil, "download disabled: src='~{0}' trg='~{1}'", xrg.Src(), xrg.Trg().Raw());
}
return false;
}
try {

View File

@@ -21,6 +21,9 @@ public class IoEngine_xrg_downloadFil {
public Io_url Trg() {return trg;} public IoEngine_xrg_downloadFil Trg_(Io_url v) {trg = v; return this;} Io_url trg;
public byte Rslt() {return rslt;} public IoEngine_xrg_downloadFil Rslt_(byte v) {rslt = v; return this;} private byte rslt = Rslt_pass;
public Exception Rslt_err() {return rslt_err;} public IoEngine_xrg_downloadFil Rslt_err_(Exception v) {rslt_err = v; return this;} Exception rslt_err;
public String Rslt_err_str() {
return rslt_err == null ? "none" : Err_.Message_gplx_brief(rslt_err);
}
public String User_agent() {return user_agent;} public IoEngine_xrg_downloadFil User_agent_(String v) {user_agent = v; return this;} private String user_agent;
public Gfo_usr_dlg Prog_dlg() {return prog_dlg;} public IoEngine_xrg_downloadFil Prog_dlg_(Gfo_usr_dlg v) {prog_dlg = v; download_fmt.Ctor(prog_dlg); return this;} Gfo_usr_dlg prog_dlg;
public Bry_fmtr Prog_fmtr() {return prog_fmtr;} Bry_fmtr prog_fmtr = Bry_fmtr.new_("~{download_header}: ~{download_read} of ~{download_length} kb;", "download_header", "download_url", "download_read", "download_length");

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx;
import org.junit.*;
public class DateAdpClassXtn_tst {
@Test public void XtoDb() {
@Test public void XtoDb() {
tst_XtoDb("20091115 220102.999", "2009-11-15 22:01:02.999");
}
void tst_XtoDb(String val, String expdRaw) {

View File

@@ -21,31 +21,31 @@ public class GfoEvMgr_tst {
@Before public void setup() {
pub = make_(); sub = make_();
} MockEvObj pub, sub;
@Test public void Basic() {
@Test public void Basic() {
GfoEvMgr_.SubSame(pub, "ev1", sub);
GfoEvMgr_.PubVal(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
GfoEvMgr_.SubSame(pub, "ev1", sub);
GfoEvMgr_.PubVal(pub, "ev2", "val1"); //ev2 does not exist
sub.tst_Handled();
}
@Test public void Lnk() {
@Test public void Lnk() {
MockEvObj mid = make_();
mid.EvMgr().Lnk(pub);
GfoEvMgr_.SubSame(mid, "ev1", sub);
GfoEvMgr_.PubVal(pub, "ev1", "val1");
sub.tst_Handled("val1");
}
@Test public void RlsSub() {
@Test public void RlsSub() {
this.Basic();
GfoEvMgr_.RlsSub(sub);
GfoEvMgr_.PubVal(pub, "ev1", "val1");
sub.tst_Handled();
}
@Test public void RlsPub() {
@Test public void RlsPub() {
this.Basic();
GfoEvMgr_.RlsSub(pub);

View File

@@ -21,11 +21,11 @@ public class GfoMsg_tst {
@Before public void setup() {
GfsCore._.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(GfoInvkXtoStr.WriteMsg(mok, Mok.Invk_Cmd0, true, 1, "a"), "Mok.Cmd0:bool0='y' int0='1' str0='a';");
mok.Int0 = 2;

View File

@@ -19,12 +19,12 @@ package gplx.stores.dsvs; import gplx.*; import gplx.stores.*;
import org.junit.*;
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"
@@ -36,7 +36,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"
@@ -48,7 +48,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"
@@ -57,7 +57,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"

View File

@@ -19,7 +19,7 @@ package gplx.stores.dsvs; import gplx.*; import gplx.stores.*;
import org.junit.*;
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"
@@ -32,7 +32,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"
@@ -44,7 +44,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 + ", ,\" \",$"
@@ -57,7 +57,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, ,\" \",@"
@@ -70,7 +70,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, ,\" \",#"

View File

@@ -23,13 +23,13 @@ public class GfsCore_tst {
core.AddObj(String_.Gfs, "String_");
core.AddObj(Int_.Gfs, "Int_");
} GfsCore core;
@Test public void Basic() { // String_.Len('abc') >> 3
@Test public void Basic() { // String_.Len('abc') >> 3
tst_Msg
( msg_("String_").Subs_
( msg_("Len").Add("v", "abc"))
, 3);
}
@Test public void PrimitiveConversion() { // String_.Len('abc').Add(-3) >> 0
@Test public void PrimitiveConversion() { // String_.Len('abc').Add(-3) >> 0
tst_Msg
( msg_("String_").Subs_
( msg_("Len").Add("v", "abc").Subs_
@@ -37,32 +37,32 @@ public class GfsCore_tst {
)
, 0);
}
// @Test public void Fail_notFound() { // String_.DoesNotExists
// @Test public void Fail_notFound() { // String_.DoesNotExists
// tst_Err
// ( msg_("help").Add("", "String_.DoesNotExist")
// , GfsHelp.Err_Unhandled("String_", "DoesNotExist"));
// }
@Test public void Cmd() { // cmd
@Test public void Cmd() { // cmd
core.AddCmd(new GfsTest_cmd(), "testCmd");
tst_Msg
( msg_("testCmd").Add("s", "pass")
, "pass");
}
@Test public void EmptyMsg() {
@Test public void EmptyMsg() {
tst_Msg
( msg_("")
, GfoInvkAble_.Rv_unhandled);
}
// @Test public void Fail_argMissing() { // String_.Len()
// @Test public void Fail_argMissing() { // String_.Len()
// tst_String__Len_Err(msg_("Len"), GfsCtx.Err_KeyNotFound("v", "<<EMPTY>>"));
// }
// @Test public void Fail_argWrongKey() { // String_.Len(badKey='abc')
// @Test public void Fail_argWrongKey() { // String_.Len(badKey='abc')
// tst_String__Len_Err(msg_("Len").Add("badKey", "abc"), GfsCtx.Err_KeyNotFound("v", "badKey;"));
// }
// @Test public void Fail_argExtraKey() { // String_.Len(v='abc' extraKey=1)
// @Test public void Fail_argExtraKey() { // String_.Len(v='abc' extraKey=1)
// tst_String__Len_Err(msg_("Len").Add("v", "abc").Add("extraKey", 1), GfsCtx.Err_KeyNotFound("v", "badKey;"));
// }
@Test public void Add_obj_deep() { // String_.Len(badKey='abc')
@Test public void Add_obj_deep() { // String_.Len(badKey='abc')
GfsCore_tst_nest obj1 = GfsCore_tst_nest.new_("1", "val1");
GfsCore_tst_nest obj1_1 = GfsCore_tst_nest.new_("1_1", "val2");
core.AddObj(obj1, "1");

View File

@@ -32,4 +32,5 @@ public interface Gfo_usr_dlg extends GfoInvkAble, Cancelable {
String Prog_one(String grp_key, String msg_key, String fmt, Object arg);
String Prog_direct(String msg);
String Log_direct(String msg);
String Plog_many(String grp_key, String msg_key, String fmt, Object... args);
}

View File

@@ -37,6 +37,7 @@ class Gfo_usr_dlg_null implements Gfo_usr_dlg {
public String Prog_one(String grp_key, String msg_key, String fmt, Object arg) {return "";}
public String Prog_direct(String msg) {return "";}
public String Log_direct(String msg) {return "";}
public String Plog_many(String grp_key, String msg_key, String fmt, Object... args) {return "";}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {return this;}
public static final Gfo_usr_dlg_null _ = new Gfo_usr_dlg_null(); Gfo_usr_dlg_null() {}
}

View File

@@ -20,19 +20,19 @@ import org.junit.*;
import gplx.ios.*; import gplx.texts.*;
public class HierStrBldr_tst {
@Before public void setup() {bldr = new HierStrBldr();} HierStrBldr bldr;
@Test public void Hier0() {
@Test public void Hier0() {
bldr.Ctor("/root/", "dir_{0}/", "idx_{0}.csv", "000");
tst_MakeName( 0, "/root/idx_000.csv");
tst_MakeName( 1, "/root/idx_001.csv");
tst_MakeName(10, "/root/idx_010.csv");
}
@Test public void Hier1() {
@Test public void Hier1() {
bldr.Ctor("/root/", "dir_{0}/", "idx_{0}.csv", "000", 10);
tst_MakeName( 0, "/root/dir_000/idx_000.csv");
tst_MakeName( 1, "/root/dir_000/idx_001.csv");
tst_MakeName(10, "/root/dir_010/idx_010.csv");
}
@Test public void Hier2() {
@Test public void Hier2() {
bldr.Ctor("/root/", "dir_{0}/", "idx_{0}.csv", "000", 5, 10);
tst_MakeName( 0, "/root/dir_000/dir_000/idx_000.csv");
tst_MakeName( 1, "/root/dir_000/dir_000/idx_001.csv");

View File

@@ -19,13 +19,13 @@ package gplx.xmls; import gplx.*;
import org.junit.*;
public class XmlDoc_tst {
String xml; XmlDoc xdoc; XmlNde xnde;
@Test public void parse_() {
@Test public void parse_() {
xml = String_.Concat("<root/>");
xdoc = XmlDoc_.parse_(xml);
Tfds.Eq("root", xdoc.Root().Name());
Tfds.Eq(true, xdoc.Root().NdeType_element());
}
@Test public void Xml_outer() {
@Test public void Xml_outer() {
xml = String_.Concat
( "<root>"
, "<a>"
@@ -39,7 +39,7 @@ public class XmlDoc_tst {
Tfds.Eq("a", xnde.Name());
Tfds.Eq("<a><b/><b/></a>", xnde.Xml_outer());
}
@Test public void Text_inner() {
@Test public void Text_inner() {
xml = String_.Concat
( "<root>"
, "<a>"
@@ -52,7 +52,7 @@ public class XmlDoc_tst {
Tfds.Eq("a", xnde.Name());
Tfds.Eq("test me", xnde.Text_inner());
}
@Test public void Atrs() {
@Test public void Atrs() {
xml = String_.Concat
( "<root atr0=\"0\" atr1=\"1\">"
, "</root>"

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xmls; import gplx.*;
import org.junit.*;
public class Xpath__tst {
@Test public void Select_all() {
@Test public void Select_all() {
String xml = String_.Concat
( "<root>"
, "<a>"

View File

@@ -21,7 +21,7 @@ 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");
@@ -34,7 +34,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");
@@ -45,7 +45,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);

View File

@@ -22,31 +22,31 @@ public class GfoMsg_rdr_tst {
msg = msg_().Add("a", "1").Add("b", "2").Add("c", "3");
ctx.Match("init", "init");
} GfoMsg msg; GfsCtx ctx = GfsCtx.new_();
@Test public void Key() {
@Test public void Key() {
tst_Msg(msg, "a", "1");
tst_Msg(msg, "b", "2");
tst_Msg(msg, "c", "3");
tst_Msg(msg, "d", null);
}
@Test public void Pos() {
@Test public void Pos() {
msg = msg_().Add("", "1").Add("", "2").Add("", "3");
tst_Msg(msg, "", "1");
tst_Msg(msg, "", "2");
tst_Msg(msg, "", "3");
tst_Msg(msg, "", null);
}
@Test public void OutOfOrder() {
@Test public void OutOfOrder() {
tst_Msg(msg, "c", "3");
tst_Msg(msg, "b", "2");
tst_Msg(msg, "a", "1");
}
@Test public void Key3_Pos1_Pos2() {
@Test public void Key3_Pos1_Pos2() {
msg = msg_().Add("", "1").Add("", "2").Add("c", "3");
tst_Msg(msg, "c", "3");
tst_Msg(msg, "", "1");
tst_Msg(msg, "", "2");
}
@Test public void MultipleEmpty() {
@Test public void MultipleEmpty() {
msg = msg_().Add("", "1").Add("", "2").Add("", "3");
tst_Msg(msg, "", "1");
tst_Msg(msg, "", "2");

View File

@@ -22,7 +22,7 @@ public class IoEngine_dir_basic_system_tst extends IoEngine_dir_basic_base {
root = Tfds.RscDir.GenSubDir_nest("100_core", "ioEngineTest", "_temp");
IoEngine_xrg_deleteDir.new_(root).Recur_().ReadOnlyFails_off().Exec();
} @Override protected IoEngine engine_() {return IoEngine_system.new_();}
@Test @Override public void ScanDir() {
@Test @Override public void ScanDir() {
super.ScanDir();
}
}

View File

@@ -23,13 +23,13 @@ public class IoEngine_fil_basic_system_tst extends IoEngine_fil_basic_base {
fil = root.GenSubFil("fil.txt");
IoEngine_xrg_deleteDir.new_(fil.OwnerDir()).Recur_().ReadOnlyFails_off().Exec();
} @Override protected IoEngine engine_() {return IoEngine_system.new_();}
@Test public void ExistsFil_IgnoreDifferentCasing() {
@Test public void ExistsFil_IgnoreDifferentCasing() {
if (root.Info().CaseSensitive()) return;
fx.run_SaveFilText(fil, "text");
fx.tst_ExistsPaths(true, fil);
fx.tst_ExistsPaths(true, fil.OwnerDir().GenSubFil("FIL.txt"));
}
@Test @gplx.Virtual public void RecycleFil() {
@Test @gplx.Virtual public void RecycleFil() {
fx.run_SaveFilText(fil, "text");
fx.tst_ExistsPaths(true, fil);
@@ -46,13 +46,13 @@ public class IoEngine_fil_basic_system_tst extends IoEngine_fil_basic_base {
fx.tst_ExistsPaths(true, fil);
fx.tst_ExistsPaths(false, recycleXrg.RecycleUrl());
}
@Test @Override public void DeleteFil_missing_pass() {
@Test @Override public void DeleteFil_missing_pass() {
super.DeleteFil_missing_pass();
}
@Test @Override public void DeleteFil_readOnly_pass() {
@Test @Override public void DeleteFil_readOnly_pass() {
super.DeleteFil_readOnly_pass ();
}
@Test @Override public void SaveFilText_readOnlyFails() {
@Test @Override public void SaveFilText_readOnlyFails() {
super.SaveFilText_readOnlyFails();
}
}

View File

@@ -18,23 +18,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.stores; import gplx.*;
import org.junit.*;
public class GfoNdeRdr_read_tst {
@Test public void ReadInt() {
@Test public void ReadInt() {
rdr = rdr_(IntClassXtn._, "id", 1);
Tfds.Eq(rdr.ReadInt("id"), 1);
}
@Test public void ReadIntOr() {
@Test public void ReadIntOr() {
rdr = rdr_(IntClassXtn._, "id", 1);
Tfds.Eq(rdr.ReadIntOr("id", -1), 1);
}
@Test public void ReadIntElse_minus1() {
@Test public void ReadIntElse_minus1() {
rdr = rdr_(IntClassXtn._, "id", null);
Tfds.Eq(rdr.ReadIntOr("id", -1), -1);
}
@Test public void ReadInt_parse() {
@Test public void ReadInt_parse() {
rdr = rdr_(StringClassXtn._, "id", "1");
Tfds.Eq(rdr.ReadInt("id"), 1);
}
@Test public void ReadIntElse_parse() {
@Test public void ReadIntElse_parse() {
rdr = rdr_(StringClassXtn._, "id", "2");
Tfds.Eq(rdr.ReadIntOr("id", -1), 2);
}

View File

@@ -18,14 +18,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.stores.xmls; import gplx.*; import gplx.stores.*;
import org.junit.*;
public class XmlDataRdr_tst {
@Test public void Read() {
@Test public void Read() {
DataRdr rdr = fx.rdr_("<title id=\"1\" name=\"first\" profiled=\"false\" />");
Tfds.Eq(rdr.NameOfNode(), "title");
Tfds.Eq(rdr.ReadStr("name"), "first");
Tfds.Eq(rdr.ReadInt("id"), 1);
Tfds.Eq(rdr.ReadBool("profiled"), false);
}
@Test public void None() {
@Test public void None() {
DataRdr rdr = fx.rdr_
( "<root>"
, "<find/>"
@@ -33,7 +33,7 @@ public class XmlDataRdr_tst {
);
fx.tst_Subs_ByName(rdr, "no_nde", "no_atr");
}
@Test public void One() {
@Test public void One() {
DataRdr rdr = fx.rdr_
( "<root>"
, "<find id=\"f0\" />"
@@ -41,7 +41,7 @@ public class XmlDataRdr_tst {
);
fx.tst_Subs_ByName(rdr, "find", "id", "f0");
}
@Test public void One_IgnoreOthers() {
@Test public void One_IgnoreOthers() {
DataRdr rdr = fx.rdr_
( "<root>"
, "<find id=\"f0\" />"
@@ -50,7 +50,7 @@ public class XmlDataRdr_tst {
);
fx.tst_Subs_ByName(rdr, "find", "id", "f0");
}
@Test public void Many() {
@Test public void Many() {
DataRdr rdr = fx.rdr_
( "<root>"
, "<find id=\"f0\" />"
@@ -59,7 +59,7 @@ public class XmlDataRdr_tst {
);
fx.tst_Subs_ByName(rdr, "find", "id", "f0", "f1");
}
@Test public void Nested() {
@Test public void Nested() {
DataRdr rdr = fx.rdr_
( "<root>"
, "<sub1>"
@@ -70,7 +70,7 @@ public class XmlDataRdr_tst {
);
fx.tst_Subs_ByName(rdr, "sub1/find", "id", "f0", "f1");
}
@Test public void Nested_IgnoreOthers() {
@Test public void Nested_IgnoreOthers() {
DataRdr rdr = fx.rdr_
( "<root>"
, "<sub1>"