#1304·guice

[Bug in test file]A little bug in InternalProvisionExceptionTest.java

Author: birdmanmandbirCreated Mar 23, 2020Updated May 21, 2026

On Windows OS, if use mvn to build the project, InternalProvisionExceptionTest.java will not pass because the line separators of windows and linux are different.

<testcase classname="com.google.inject.internal.InternalProvisionExceptionTest" name="testSourceFormatting" time="    0.172">
     <failure message="value of: getMessage()
 diff    : (line contents match, but line-break characters differ)" type="value of">value of: getMessage()
 diff    : (line contents match, but line-break characters differ)
         at com.google.inject.internal.InternalProvisionExceptionTest.testSourceFormatting(InternalProvisionException    Test.java:35)
java
package com.google.inject.internal;

import static com.google.common.truth.Truth.assertThat;

import com.google.inject.internal.util.SourceProvider;
import junit.framework.TestCase;

public final class InternalProvisionExceptionTest extends TestCase {

  public void testSourceFormatting() {
    // Note that the duplicate source gets dropped as well as the unknown source
    assertThat(
            InternalProvisionException.create("An error")
                .addSource("Source1")
                .addSource(SourceProvider.UNKNOWN_SOURCE)
                .addSource("Source2")
                .addSource("Source2")
                .toProvisionException()
                .getMessage())
        .isEqualTo(
            ""
                + "Unable to provision, see the following errors:\n"
                + "\n"
                + "1) An error\n"
                + "  at Source1\n"
                + "  at Source2\n"
                + "\n"
                + "1 error");
  }
}

\n could be replaced with System.lineSeparator() to solve this bug.

And I'd like to make a pull request for this.