1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-10-27 20:34:16 +00:00

Bldr: Add omitted tests for normalizing title, timestamp

This commit is contained in:
gnosygnu 2017-03-06 20:42:56 -05:00
parent 5b2f3136a2
commit 848496c51b
3 changed files with 45 additions and 4 deletions

View File

@ -79,7 +79,7 @@ class Xobldr_missing_origs_item {
this.lnki_ext = Xof_ext_.new_by_ttl_(lnki_ttl).Id();
this.orig_redirect_ext = Xof_ext_.new_by_ttl_(orig_redirect_ttl).Id();
}
private static byte[] Normalize_ttl(byte[] v) {
public static byte[] Normalize_ttl(byte[] v) {
// remove "File:"
if (Bry_.Has_at_bgn(v, Xobldr_missing_origs_wmfapi.FILE_NS_PREFIX)) {
v = Bry_.Mid(v, Xobldr_missing_origs_wmfapi.FILE_NS_PREFIX.length);
@ -93,7 +93,7 @@ class Xobldr_missing_origs_item {
return v;
}
private static byte[] Normalize_minor_mime(byte[] src) {
public static byte[] Normalize_minor_mime(byte[] src) {
// convert "image/svg+xml" to "svg+xml"
int src_len = src.length;
int slash_pos = Bry_find_.Find_fwd(src, Byte_ascii.Slash, 0, src_len);
@ -102,7 +102,7 @@ class Xobldr_missing_origs_item {
}
return Bry_.Mid(src, slash_pos + 1, src_len);
}
private static byte[] Normalize_timestamp(byte[] src) {
public static byte[] Normalize_timestamp(byte[] src) {
// convert 2017-03-06T08:09:10Z to 20170306080910
byte[] rv = new byte[14];
int rv_idx = 0;

View File

@ -0,0 +1,41 @@
/*
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.xowa.addons.bldrs.files.missing_origs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.files.*;
import org.junit.*; import gplx.core.tests.*;
public class Xobldr_missing_origs_item__tst {
private final Xobldr_missing_origs_item__fxt fxt = new Xobldr_missing_origs_item__fxt();
@Test public void Normalize_ttl() {
fxt.Test__Normalize_ttl("File:A b.png", "A_b.png");
}
@Test public void Normalize_minor_mime() {
fxt.Test__Normalize_minor_mime("image/svg+xml", "svg+xml");
}
@Test public void Normalize_timestamp() {
fxt.Test__Normalize_timestamp("2017-03-06T08:09:10Z", "20170306080910");
}
}
class Xobldr_missing_origs_item__fxt {
public void Test__Normalize_ttl(String src, String expd) {
Gftest.Eq__str(expd, Xobldr_missing_origs_item.Normalize_ttl(Bry_.new_u8(src)));
}
public void Test__Normalize_timestamp(String src, String expd) {
Gftest.Eq__str(expd, Xobldr_missing_origs_item.Normalize_timestamp(Bry_.new_u8(src)));
}
public void Test__Normalize_minor_mime(String src, String expd) {
Gftest.Eq__str(expd, Xobldr_missing_origs_item.Normalize_minor_mime(Bry_.new_u8(src)));
}
}

View File

@ -1 +1 @@
v4.3.0.4
v4.4.0.1