public void testCPathEntriesForOldStyle() throws Exception {
    p2 = CProjectHelper.createCCProject(PROJ_NAME_PREFIX + "b", null, IPDOMManager.ID_NO_INDEXER);
    ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
    IProject project = p2.getProject();
    ICProjectDescription des = mngr.getProjectDescription(project, false);
    assertNotNull(des);
    assertEquals(1, des.getConfigurations().length);
    assertFalse(mngr.isNewStyleProject(des));
    assertFalse(mngr.isNewStyleProject(project));

    IPathEntry[] entries = CoreModel.getRawPathEntries(p2);
    entries =
        concatEntries(
            entries,
            new IPathEntry[] {
              CoreModel.newSourceEntry(project.getFullPath().append("test_src")),
              CoreModel.newOutputEntry(project.getFullPath().append("test_out")),
            });

    CoreModel.setRawPathEntries(p2, entries, null);

    ICSourceEntry[] expectedSourceEntries =
        new ICSourceEntry[] {
          new CSourceEntry(
              project.getFullPath(), new IPath[] {new Path("test_src")}, ICSettingEntry.RESOLVED),
          new CSourceEntry(project.getFullPath().append("test_src"), null, ICSettingEntry.RESOLVED),
        };

    ICOutputEntry[] expectedOutputEntries =
        new ICOutputEntry[] {
          new COutputEntry(
              project.getFullPath(),
              null,
              ICSettingEntry.RESOLVED | ICSettingEntry.VALUE_WORKSPACE_PATH),
          new COutputEntry(
              project.getFullPath().append("test_out"),
              null,
              ICSettingEntry.RESOLVED | ICSettingEntry.VALUE_WORKSPACE_PATH),
        };

    des = mngr.getProjectDescription(project, false);
    ICConfigurationDescription cfg = des.getDefaultSettingConfiguration();
    ICSourceEntry[] sEntries = cfg.getSourceEntries();
    ICOutputEntry[] oEntries = cfg.getBuildSetting().getOutputDirectories();

    checkCEntriesMatch(expectedSourceEntries, sEntries);
    checkCEntriesMatch(expectedOutputEntries, oEntries);

    des = mngr.getProjectDescription(project, true);
    cfg = des.getDefaultSettingConfiguration();
    sEntries = cfg.getSourceEntries();
    oEntries = cfg.getBuildSetting().getOutputDirectories();

    checkCEntriesMatch(expectedSourceEntries, sEntries);
    checkCEntriesMatch(expectedOutputEntries, oEntries);
  }
  public void testPathEntriesForNewStyle() throws Exception {
    p1 =
        CProjectHelper.createNewStileCProject(
            PROJ_NAME_PREFIX + "a",
            TestUserAndDiscoveredEntriesCfgDataProvider.PROVIDER_ID,
            IPDOMManager.ID_NO_INDEXER);
    IProject project = p1.getProject();

    IPathEntry[] entries = CoreModel.getRawPathEntries(p1);
    IPathEntry[] resolvedentries = CoreModel.getResolvedPathEntries(p1);
    IPathEntry[] expectedRawEntries =
        new IPathEntry[] {
          CoreModel.newContainerEntry(new Path("org.eclipse.cdt.core.CFG_BASED_CONTAINER")),
          CoreModel.newSourceEntry(project.getFullPath()),
          CoreModel.newOutputEntry(project.getFullPath()),
        };
    checkEntriesMatch(expectedRawEntries, entries);

    IPathEntry[] expectedResolvedEntries =
        new IPathEntry[] {
          CoreModel.newSourceEntry(project.getFullPath()),
          CoreModel.newOutputEntry(project.getFullPath()),
          CoreModel.newMacroEntry(project.getFullPath(), "a", "b"),
          CoreModel.newMacroEntry(project.getFullPath(), "c", ""),
          CoreModel.newIncludeEntry(
              project.getFullPath(), null, project.getLocation().append("a/b/c")),
          CoreModel.newIncludeEntry(project.getFullPath(), null, new Path("/d/e/f")),
          CoreModel.newIncludeEntry(
              project.getFullPath(), project.getFullPath().makeRelative(), new Path("g/h/i")),
          CoreModel.newIncludeEntry(project.getFullPath(), new Path("j"), new Path("k/l")),
        };
    checkEntriesMatch(expectedResolvedEntries, resolvedentries);

    IPathEntry[] newEntries = new IPathEntry[entries.length + 1];
    System.arraycopy(entries, 0, newEntries, 0, entries.length);
    newEntries[entries.length] =
        CoreModel.newIncludeEntry(
            new Path("d"),
            null,
            new Path("/C/d/e"),
            true,
            new Path[] {new Path("a"), new Path("b")},
            false);

    IPathEntry[] newExpectedRawEntries = new IPathEntry[entries.length + 1];
    System.arraycopy(entries, 0, newExpectedRawEntries, 0, entries.length);
    newExpectedRawEntries[entries.length] =
        CoreModel.newIncludeEntry(
            project.getFullPath().append("d"),
            null,
            new Path("/C/d/e"),
            true,
            new Path[] {new Path("a"), new Path("b")},
            false);

    CoreModel.setRawPathEntries(p1, newEntries, null);

    entries = CoreModel.getRawPathEntries(p1);
    checkEntriesMatch(entries, newExpectedRawEntries);

    IPathEntry[] newExpectedResolved = new IPathEntry[resolvedentries.length + 1];
    System.arraycopy(resolvedentries, 0, newExpectedResolved, 0, resolvedentries.length);
    newExpectedResolved[resolvedentries.length] =
        CoreModel.newIncludeEntry(
            project.getFullPath().append("d"),
            null,
            new Path("/C/d/e"),
            true,
            new Path[] {new Path("a"), new Path("b")},
            false);
    resolvedentries = CoreModel.getResolvedPathEntries(p1);
    checkEntriesMatch(resolvedentries, newExpectedResolved);

    entries =
        concatEntries(
            entries,
            new IPathEntry[] {
              CoreModel.newSourceEntry(project.getFullPath().append("test_src")),
              CoreModel.newOutputEntry(project.getFullPath().append("test_out")),
            });

    newExpectedRawEntries =
        concatEntries(
            newExpectedRawEntries,
            new IPathEntry[] {
              CoreModel.newSourceEntry(project.getFullPath().append("test_src")),
              CoreModel.newOutputEntry(project.getFullPath().append("test_out")),
            });

    for (int i = 0; i < newExpectedRawEntries.length; i++) {
      IPathEntry entry = newExpectedRawEntries[i];
      if (entry.getEntryKind() == IPathEntry.CDT_SOURCE
          && entry.getPath().equals(project.getFullPath())) {
        newExpectedRawEntries[i] =
            CoreModel.newSourceEntry(project.getFullPath(), new Path[] {new Path("test_src")});
      }
      //			if(entry.getEntryKind() == IPathEntry.CDT_OUTPUT &&
      // entry.getPath().equals(project.getFullPath())){
      //				newExpectedRawEntries[i] = CoreModel.newOutputEntry(project.getFullPath(), new
      // Path[]{new Path("test_out")});
      //			}
    }

    newExpectedResolved =
        concatEntries(
            newExpectedResolved,
            new IPathEntry[] {
              CoreModel.newSourceEntry(project.getFullPath().append("test_src")),
              CoreModel.newOutputEntry(project.getFullPath().append("test_out")),
            });

    for (int i = 0; i < newExpectedResolved.length; i++) {
      IPathEntry entry = newExpectedResolved[i];
      if (entry.getEntryKind() == IPathEntry.CDT_SOURCE
          && entry.getPath().equals(project.getFullPath())) {
        newExpectedResolved[i] =
            CoreModel.newSourceEntry(project.getFullPath(), new Path[] {new Path("test_src")});
      }
      //			if(entry.getEntryKind() == IPathEntry.CDT_OUTPUT &&
      // entry.getPath().equals(project.getFullPath())){
      //				newExpectedResolved[i] = CoreModel.newOutputEntry(project.getFullPath(), new Path[]{new
      // Path("test_out")});
      //			}
    }

    CoreModel.setRawPathEntries(p1, entries, null);

    entries = CoreModel.getRawPathEntries(p1);
    resolvedentries = CoreModel.getResolvedPathEntries(p1);

    checkEntriesMatch(newExpectedRawEntries, entries);
    checkEntriesMatch(newExpectedResolved, resolvedentries);

    CoreModel.setRawPathEntries(p1, expectedRawEntries, null);
    entries = CoreModel.getRawPathEntries(p1);
    resolvedentries = CoreModel.getResolvedPathEntries(p1);

    checkEntriesMatch(expectedRawEntries, entries);
    checkEntriesMatch(expectedResolvedEntries, resolvedentries);

    // check to see that setting the same entries do not give errors
    CoreModel.setRawPathEntries(p1, expectedRawEntries, null);
    entries = CoreModel.getRawPathEntries(p1);
    resolvedentries = CoreModel.getResolvedPathEntries(p1);

    checkEntriesMatch(expectedRawEntries, entries);
    checkEntriesMatch(expectedResolvedEntries, resolvedentries);
  }