mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.12.1.1
This commit is contained in:
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
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 EnmParser_tst {
|
||||
@Before public void setup() {
|
||||
parser = EnmMgr.new_();
|
||||
}
|
||||
@Test public void Basic() { // 1,2,4,8
|
||||
parser.BitRngEnd_(8);
|
||||
run_Reg(0, "zero");
|
||||
run_Reg(1, "one");
|
||||
run_Reg(2, "two");
|
||||
run_Reg(4, "four");
|
||||
run_Reg(8, "eight");
|
||||
|
||||
tst_Convert("zero", 0);
|
||||
tst_Convert("one", 1);
|
||||
tst_Convert("eight", 8);
|
||||
tst_Convert("one+eight", 9);
|
||||
}
|
||||
@Test public void Keys() {
|
||||
parser.BitRngBgn_(65536).BitRngEnd_(262144);
|
||||
run_Reg( 65, "a");
|
||||
run_Reg( 65536, "shift");
|
||||
run_Reg(131072, "ctrl");
|
||||
run_Reg(262144, "alt");
|
||||
tst_Convert("a", 65);
|
||||
tst_Convert("shift+a", 65 + 65536);
|
||||
tst_Convert("ctrl+a", 65 + 131072);
|
||||
tst_Convert("shift+ctrl+a", 65 + 65536 + 131072);
|
||||
}
|
||||
@Test public void Prefix() {
|
||||
parser.Prefix_("key.").BitRngBgn_(128).BitRngEnd_(128);
|
||||
run_Reg(65, "a");
|
||||
tst_Convert("key.a", 65);
|
||||
}
|
||||
void run_Reg(int i, String s) {parser.RegObj(i, s, "NULL");}
|
||||
void tst_Convert(String raw, int val) {
|
||||
int actlVal = parser.GetVal(raw);
|
||||
Tfds.Eq(val, actlVal);
|
||||
Tfds.Eq(raw, parser.GetStr(val));
|
||||
}
|
||||
EnmMgr parser;
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
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.core.ios; import gplx.*; import gplx.core.*;
|
||||
public class IoEngineFxt {
|
||||
IoEngine EngineOf(Io_url url) {return IoEnginePool.Instance.Get_by(url.Info().EngineKey());}
|
||||
public void tst_ExistsPaths(boolean expd, Io_url... ary) {
|
||||
for (Io_url fil : ary) {
|
||||
if (fil.Type_dir())
|
||||
Tfds.Eq(expd, EngineOf(fil).ExistsDir(fil), "ExistsDir failed; dir={0}", fil);
|
||||
else
|
||||
Tfds.Eq(expd, EngineOf(fil).ExistsFil_api(fil), "ExistsFil failed; fil={0}", fil);
|
||||
}
|
||||
}
|
||||
public void tst_LoadFilStr(Io_url fil, String expd) {Tfds.Eq(expd, EngineOf(fil).LoadFilStr(IoEngine_xrg_loadFilStr.new_(fil)));}
|
||||
public void run_SaveFilText(Io_url fil, String expd) {EngineOf(fil).SaveFilText_api(IoEngine_xrg_saveFilStr.new_(fil, expd));}
|
||||
public void run_UpdateFilModifiedTime(Io_url fil, DateAdp modifiedTime) {EngineOf(fil).UpdateFilModifiedTime(fil, modifiedTime);}
|
||||
public void tst_QueryFilReadOnly(Io_url fil, boolean expd) {Tfds.Eq(expd, EngineOf(fil).QueryFil(fil).ReadOnly());}
|
||||
public IoEngineFxt tst_QueryFil_size(Io_url fil, long expd) {Tfds.Eq(expd, EngineOf(fil).QueryFil(fil).Size()); return this;}
|
||||
public IoEngineFxt tst_QueryFil_modifiedTime(Io_url fil, DateAdp expd) {Tfds.Eq_date(expd, EngineOf(fil).QueryFil(fil).ModifiedTime()); return this;}
|
||||
public IoItmDir tst_ScanDir(Io_url dir, Io_url... expd) {
|
||||
IoItmDir dirItem = EngineOf(dir).QueryDir(dir);
|
||||
Io_url[] actl = new Io_url[dirItem.SubDirs().Count() + dirItem.SubFils().Count()];
|
||||
for (int i = 0; i < dirItem.SubDirs().Count(); i++) {
|
||||
IoItmDir subDir = IoItmDir_.as_(dirItem.SubDirs().Get_at(i));
|
||||
actl[i] = subDir.Url();
|
||||
}
|
||||
for (int i = 0; i < dirItem.SubFils().Count(); i++) {
|
||||
IoItmFil subFil = IoItmFil_.as_(dirItem.SubFils().Get_at(i));
|
||||
actl[i + dirItem.SubDirs().Count()] = subFil.Url();
|
||||
}
|
||||
Tfds.Eq_ary_str(expd, actl);
|
||||
return dirItem;
|
||||
}
|
||||
public static IoEngineFxt new_() {
|
||||
IoEngineFxt rv = new IoEngineFxt();
|
||||
return rv;
|
||||
}
|
||||
public IoEngineFxt() {}
|
||||
}
|
||||
Reference in New Issue
Block a user