google / google/guice

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

Open
#1,304 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
12.7k
Forks
1.7k
Avg merge
11m
Merged PRs (30d)
2

Description

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.
```

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.