mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Wikibase: Do not cast 'numeric-id' to 'string'; leave as 'int'
This commit is contained in:
parent
873968b27f
commit
2b5b238bc1
@ -408,6 +408,13 @@ public class Scrib_lib_wikibase_srl_tst {
|
||||
, ""
|
||||
);
|
||||
}
|
||||
@Test public void Numeric_id_is_int() { // PURPOSE: assert that numeric-id is integer, not String, else will fail when comparing directly to integer; PAGE:en.w:Hollywood_Walk_of_Fame DATE:2016-12-17
|
||||
Wbase_claim_entity claim = (Wbase_claim_entity)fxt.Wdata_fxt().Make_claim_entity_qid(123, 456);
|
||||
Scrib_lib_wikibase_srl_visitor visitor = new Scrib_lib_wikibase_srl_visitor();
|
||||
visitor.Visit_entity(claim);
|
||||
Keyval keyval = Keyval_find_.Find(true, visitor.Rv(), "value", "numeric-id");
|
||||
Gftest.Eq__int(456, (int)keyval.Val()); // NOTE: must be 456 not "456"
|
||||
}
|
||||
}
|
||||
class Scrib_lib_wikibase_srl_fxt {
|
||||
private Wdata_doc_bldr wdoc_bldr;
|
||||
|
@ -33,7 +33,7 @@ class Scrib_lib_wikibase_srl_visitor implements Wbase_claim_visitor {
|
||||
Wbase_claim_entity claim_entity = (Wbase_claim_entity)itm;
|
||||
Keyval[] rv = new Keyval[2];
|
||||
rv[0] = Keyval_.new_(Wbase_claim_entity_.Itm__entity_type.Key_str(), claim_entity.Entity_tid_str());
|
||||
rv[1] = Keyval_.new_(Wbase_claim_entity_.Itm__numeric_id.Key_str(), Int_.To_str(claim_entity.Entity_id()));
|
||||
rv[1] = Keyval_.new_(Wbase_claim_entity_.Itm__numeric_id.Key_str(), claim_entity.Entity_id()); // NOTE: must be int, not String, else will fail when comparing directly to integer; PAGE:en.w:Hollywood_Walk_of_Fame DATE:2016-12-17
|
||||
return rv;
|
||||
}
|
||||
public void Visit_monolingualtext(Wbase_claim_monolingualtext itm) {
|
||||
|
Loading…
Reference in New Issue
Block a user