GfoMsg_rdr_tst.java 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. XOWA: the XOWA Offline Wiki Application
  3. Copyright (C) 2012-2017 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;
  13. import org.junit.*;
  14. public class GfoMsg_rdr_tst {
  15. @Before public void setup() {
  16. msg = msg_().Add("a", "1").Add("b", "2").Add("c", "3");
  17. ctx.Match("init", "init");
  18. } GfoMsg msg; GfsCtx ctx = GfsCtx.new_();
  19. @Test public void Key() {
  20. tst_Msg(msg, "a", "1");
  21. tst_Msg(msg, "b", "2");
  22. tst_Msg(msg, "c", "3");
  23. tst_Msg(msg, "d", null);
  24. }
  25. @Test public void Pos() {
  26. msg = msg_().Add("", "1").Add("", "2").Add("", "3");
  27. tst_Msg(msg, "", "1");
  28. tst_Msg(msg, "", "2");
  29. tst_Msg(msg, "", "3");
  30. tst_Msg(msg, "", null);
  31. }
  32. @Test public void OutOfOrder() {
  33. tst_Msg(msg, "c", "3");
  34. tst_Msg(msg, "b", "2");
  35. tst_Msg(msg, "a", "1");
  36. }
  37. @Test public void Key3_Pos1_Pos2() {
  38. msg = msg_().Add("", "1").Add("", "2").Add("c", "3");
  39. tst_Msg(msg, "c", "3");
  40. tst_Msg(msg, "", "1");
  41. tst_Msg(msg, "", "2");
  42. }
  43. @Test public void MultipleEmpty() {
  44. msg = msg_().Add("", "1").Add("", "2").Add("", "3");
  45. tst_Msg(msg, "", "1");
  46. tst_Msg(msg, "", "2");
  47. tst_Msg(msg, "", "3");
  48. }
  49. GfoMsg msg_() {return GfoMsg_.new_parse_("test");}
  50. void tst_Msg(GfoMsg m, String k, String expd) {Tfds.Eq(expd, m.ReadStrOr(k, null));}
  51. }