Code example for StringWriter

Methods: toStringwrite

0
        Change ch= getRefactorChanges(cpp, offset1, "xxx");  //$NON-NLS-1$
        assertTotalChanges(1, 1, 0, ch);
    } 
 
    public void testRenameMacroAsMacroArgument() throws Exception { 
        StringWriter writer = new StringWriter();
        writer.write("#define M1(var) var       \n"); //$NON-NLS-1$
        writer.write("#define M2 1              \n"); //$NON-NLS-1$
        writer.write("int b= M2;                \n"); //$NON-NLS-1$        
        writer.write("int a= M1(M2);            \n"); //$NON-NLS-1$
        String contents = writer.toString();
        IFile cpp= importFile("test.cpp", contents ); //$NON-NLS-1$
         
        int offset1= contents.indexOf("M2"); //$NON-NLS-1$
        Change ch= getRefactorChanges(cpp, offset1, "xxx");  //$NON-NLS-1$
        assertTotalChanges(countOccurrences(contents, "M2"), ch); //$NON-NLS-1$
    }         
}