Skip to content

assert.InEpsilon does not fail when passed a NaN value #918

Closed

Description

@hectorj

Hi! We ran into a small isue today with require.InEpsilon, at version 1.5.1

func TestInEpsilonNaN(t *testing.T) {
	require.InEpsilon(t, 42, math.NaN(), 1)
}

Actual result : test passes

Expected result : an error

Activity

  1. hectorj commented on Apr 1, 2020

    @hectorj
    ContributorAuthor

    This is highly similar to #162

    I'll make a PR with the equivalent changes

  2. added a commit that references this issue on Apr 2, 2020
    0129674
  3. ybrustin-te commented on Oct 16, 2024

    @ybrustin-te
    func TestInEpsilon1(t *testing.T) {
    	div := 0.0
    	require.InEpsilon(t, 1, 1/div, 0.001)
    }
    
    func TestInEpsilon2(t *testing.T) {
    	div := 0.0
    	require.InEpsilon(t, 1/div, 1, 0.001)
    }
    
    > go test -v -run InEps | grep -E '(PASS|FAIL)'
    --- FAIL: TestInEpsilon1 (0.00s)
    --- PASS: TestInEpsilon2 (0.00s)
    
  4. changed the title [-]InEpsilon does not fail when passed a NaN value[/-] [+]assert.InEpsilon does not fail when passed a NaN value[/+] on May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions