         XCTAssertEqual("single_import_enum: IMPORT_BAZ\n", a.textFormatString())
 
         assertTextFormatEncode("single_import_enum: IMPORT_BAZ\n") {(o: inout MessageTestType) in o.singleImportEnum = .importBaz }
+        assertTextFormatDecodeSucceeds("single_import_enum: 9\n") {(o: MessageTestType) in o.singleImportEnum == .importBaz }
+
+        assertTextFormatEncode("single_import_enum: 66\n") {(o: inout MessageTestType) in o.singleImportEnum = .UNRECOGNIZED(66) }
 
         assertTextFormatDecodeFails("single_import_enum: a\n")
     }

            o.repeatedForeignEnum = [.foreignBar, .foreignBaz]
        }

        assertTextFormatDecodeFails("repeated_foreign_enum: FOREIGN_BAR\nrepeated_foreign_enum: a\n")
    }

    func testEncoding_repeatedImportEnum() {
        assertTextFormatEncode("repeated_import_enum: [IMPORT_BAR, IMPORT_BAZ]\n") {(o: inout MessageTestType) in
            o.repeatedImportEnum = [.importBar, .importBaz]
        }

        assertTextFormatDecodeFails("repeated_import_enum: IMPORT_BAR\nrepeated_import_enum: a\n")

        XCTAssertEqual("single_foreign_enum: FOREIGN_BAZ\n", a.textFormatString())

        assertTextFormatEncode("single_foreign_enum: FOREIGN_BAZ\n") {(o: inout MessageTestType) in o.singleForeignEnum = .foreignBaz }
        assertTextFormatDecodeSucceeds("single_foreign_enum: 6\n") {(o: MessageTestType) in o.singleForeignEnum == .foreignBaz }

        assertTextFormatEncode("single_foreign_enum: 99\n") {(o: inout MessageTestType) in o.singleForeignEnum = .UNRECOGNIZED(99) }

        assertTextFormatDecodeFails("single_foreign_enum: a\n")
    }
