예제 #1
0
    def test_enums(self):
        expected = '''enum class EnumA(override val value: Long): MessageEnum {
    OptionA(1), OptionB(2), OptionC(4), OptionD(5);
    companion object {
        fun construct(value: Long): EnumA {
            return values().first { it.value == value }
        }
    }
}
'''
        observed = language.enums(MsgParser.Enums(self.msgDict))
        self.assertMultiLineEqual(expected, observed)
예제 #2
0
    def test_enums(self):
        expected = '''public enum EnumA {
    OptionA(1), OptionB(2), OptionC(4), OptionD(5);
    private final long id;
    EnumA(long id) { this.id = id; }
    static Map<Long, EnumA> map = new HashMap<>();
    static {
        for (EnumA key : EnumA.values()) {
            map.put(key.id, key);
        }
    }
    public long intValue() { return id; }
    public static EnumA construct(long value) { return map.get(value); }
}
'''
        observed = language.enums(MsgParser.Enums(self.msgDict))
        self.assertMultiLineEqual(expected, observed)
예제 #3
0
 def test_enums(self):
     expected = 'enum class EnumA {OptionA = 1, OptionB = 2, OptionC = 4, OptionD = 5};\n'
     observed = language.enums(MsgParser.Enums(self.msgDict))
     self.assertMultiLineEqual(expected, observed)
예제 #4
0
 def test_enums(self):
     expected = 'EnumA = OrderedDict([("OptionA", 1), ("OptionB", 2), ("OptionC", 4), ("OptionD", 5)])\nReverseEnumA = OrderedDict([(1, "OptionA"), (2, "OptionB"), (4, "OptionC"), (5, "OptionD")])\n'
     observed = language.enums(MsgParser.Enums(self.msgDict))
     self.assertMultiLineEqual(expected, observed)