Skip to content

Failing assertion for enum fields #1704

Open
@sofurihafe

Description

@sofurihafe

Description

Seems like the problem with the engine.

To Reproduce

Steps to reproduce the behavior:

  1. Set the following settings for the estimator:
timeLimit = 160
methodFilter = "com.google.common.base.CaseFormat.*"
projectFilter = listOf("guava-26.0")
  1. Find testDoForward generated test.

Expected behavior

Correct assertion types. Passing assertions.

Actual behavior
Assertion for false fails (the last statement):

@Test
public void testDoForward() throws Exception  {
    Object stringConverter = createInstance("com.google.common.base.CaseFormat$StringConverter");
    CaseFormat anonymousCaseFormat = ((CaseFormat) createInstance("com.google.common.base.CaseFormat$4"));
    setField(stringConverter, "com.google.common.base.CaseFormat$StringConverter", "sourceFormat", anonymousCaseFormat);
    setField(stringConverter, "com.google.common.base.CaseFormat$StringConverter", "targetFormat", anonymousCaseFormat);
    String string = "";
    
    CaseFormat initialStringConverterSourceFormat = ((CaseFormat) getFieldValue(stringConverter, "com.google.common.base.CaseFormat$StringConverter", "sourceFormat"));
    
    Class stringConverterClazz = Class.forName("com.google.common.base.CaseFormat$StringConverter");
    Class stringType = Class.forName("java.lang.String");
    Method doForwardMethod = stringConverterClazz.getDeclaredMethod("doForward", stringType);
    doForwardMethod.setAccessible(true);
    java.lang.Object[] doForwardMethodArguments = new java.lang.Object[1];
    doForwardMethodArguments[0] = string;
    String actual = ((String) doForwardMethod.invoke(stringConverter, doForwardMethodArguments));
    
    assertEquals(string, actual);
    
    CaseFormat finalStringConverterSourceFormat = ((CaseFormat) getFieldValue(stringConverter, "com.google.common.base.CaseFormat$StringConverter", "sourceFormat"));
    
    assertFalse(initialStringConverterSourceFormat == finalStringConverterSourceFormat);
}

image

image

image

Metadata

Metadata

Assignees

Labels

comp-codegenIssue is related to code generatorcomp-contest-estimatorIssue is related to contest estimatorctg-bugIssue is a bug

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions