GfoMsg_rdr_tst.java 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. XOWA: the XOWA Offline Wiki Application
  3. Copyright (C) 2012 gnosygnu@gmail.com
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU Affero General Public License as
  6. published by the Free Software Foundation, either version 3 of the
  7. License, or (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package gplx;
  16. import org.junit.*;
  17. public class GfoMsg_rdr_tst {
  18. @Before public void setup() {
  19. msg = msg_().Add("a", "1").Add("b", "2").Add("c", "3");
  20. ctx.Match("init", "init");
  21. } GfoMsg msg; GfsCtx ctx = GfsCtx.new_();
  22. @Test public void Key() {
  23. tst_Msg(msg, "a", "1");
  24. tst_Msg(msg, "b", "2");
  25. tst_Msg(msg, "c", "3");
  26. tst_Msg(msg, "d", null);
  27. }
  28. @Test public void Pos() {
  29. msg = msg_().Add("", "1").Add("", "2").Add("", "3");
  30. tst_Msg(msg, "", "1");
  31. tst_Msg(msg, "", "2");
  32. tst_Msg(msg, "", "3");
  33. tst_Msg(msg, "", null);
  34. }
  35. @Test public void OutOfOrder() {
  36. tst_Msg(msg, "c", "3");
  37. tst_Msg(msg, "b", "2");
  38. tst_Msg(msg, "a", "1");
  39. }
  40. @Test public void Key3_Pos1_Pos2() {
  41. msg = msg_().Add("", "1").Add("", "2").Add("c", "3");
  42. tst_Msg(msg, "c", "3");
  43. tst_Msg(msg, "", "1");
  44. tst_Msg(msg, "", "2");
  45. }
  46. @Test public void MultipleEmpty() {
  47. msg = msg_().Add("", "1").Add("", "2").Add("", "3");
  48. tst_Msg(msg, "", "1");
  49. tst_Msg(msg, "", "2");
  50. tst_Msg(msg, "", "3");
  51. }
  52. GfoMsg msg_() {return GfoMsg_.new_parse_("test");}
  53. void tst_Msg(GfoMsg m, String k, String expd) {Tfds.Eq(expd, m.ReadStrOr(k, null));}
  54. }