Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

IsZero has no effect on slices #23

@adamhassel

Description

@adamhassel

No matter the setting of the IsZero option, nil and empty initialized slices are always considered the same.

Drawing from the TestHash_equalNil test function, adding this case will break tests:

{
	Test{
		Str:   nil,
		Int:   nil,
		Map:   nil,
		Slice: nil,
	},
	Test{
		Str:   nil,
		Int:   nil,
		Map:   nil,
		Slice: make([]string, 0),
	},
	false,
	false,
},

This test sets (first false) ZeroNil to false (thus differing nil from []string{}), and subsequently expects the hashes to be different (second false).

Changing the second false to true (thereby expecting same hashes from the two tests) passes the test, which obviously shouldn't be the case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions