1
0

ObjectUtlTest.java 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. XOWA: the XOWA Offline Wiki Application
  3. Copyright (C) 2012-2021 gnosygnu@gmail.com
  4. XOWA is licensed under the terms of the General Public License (GPL) Version 3,
  5. or alternatively under the terms of the Apache License Version 2.0.
  6. You may use XOWA according to either of these licenses as is most appropriate
  7. for your project on a case-by-case basis.
  8. The terms of each license can be found in the source code repository:
  9. GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
  10. Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
  11. */
  12. package gplx.objects;
  13. import gplx.frameworks.tests.GfoTstr;
  14. import gplx.types.basics.utls.ObjectUtl;
  15. import org.junit.Before;
  16. import org.junit.Test;
  17. public class ObjectUtlTest {
  18. private ObjectUtlTstr tstr = new ObjectUtlTstr();
  19. @Before public void init() {}
  20. @Test public void Eq() {
  21. tstr.TestEq(null, null, true); // both null
  22. tstr.TestEq(5, 5, true); // both non-null
  23. tstr.TestEq(5, null, false); // rhs non-null
  24. tstr.TestEq(null, 5, false); // lhs non-null
  25. }
  26. @Test public void ToStrLooseOrNull() {
  27. tstr.TestToStrLooseOrNull(null, null);
  28. tstr.TestToStrLooseOrNull(2449.6000000000004d, "2449.6");
  29. }
  30. }
  31. class ObjectUtlTstr {
  32. public void TestEq(Object lhs, Object rhs, boolean expd) {GfoTstr.Eq(expd, ObjectUtl.Eq(lhs, rhs));}
  33. public void TestToStrLooseOrNull(Object v, String expd) {GfoTstr.Eq(expd, ObjectUtl.ToStrLooseOr(v, null));}
  34. }