Giter Site home page Giter Site logo

Comments (9)

rana avatar rana commented on August 11, 2024 2

Btw, great package! I don't know how i lived without it before!

from assertions.

joliver avatar joliver commented on August 11, 2024

I like the idea. It definitely makes it feel better than ShouldResemble.

from assertions.

SunSparc avatar SunSparc commented on August 11, 2024

ShouldResemble works fine for me, but perhaps ShouldEqual would be better since it is more intuitive for those that are new to the assertions package. Or perhaps the ShouldEqual could just detect if it is trying to be used on structs and print a message that redirects users to ShouldResemble.

from assertions.

mdwhatcott avatar mdwhatcott commented on August 11, 2024

The ShouldResemble function sometimes fall over when comparing time values that are in different time zones. The .Equal() method compares the actual instant, regardless of time zone, so that's why it's a compelling option.

from assertions.

rana avatar rana commented on August 11, 2024

I get "Equal" immediately. "Resemble" implies kind of equal? Perhaps in some circumstances? I'm sure i could look up the docs, but for something as basic as time.Time I just wrote my own assertion to make sure time is really equal.

from assertions.

mdwhatcott avatar mdwhatcott commented on August 11, 2024

Yes @rana, in retrospect, it probably just should have been ShouldDeepEqual rather than ShouldResemble. The word "resemble" doesn't have as strong a connotation as "equal". But I liked the definition, which referenced two things that have similar qualities/features (fields!):

re·sem·ble
rəˈzembəl
verb
have qualities or features, especially those of appearance, in common with (someone or something);

from assertions.

rana avatar rana commented on August 11, 2024

Sounds good!

from assertions.

rana avatar rana commented on August 11, 2024

You might find https://github.com/google/go-cmp useful for future works on the assertions package. Google created a new package for DeepEqual:

This package is intended to be a more powerful and safer alternative to reflect.DeepEqual for comparing whether two values are semantically equal.

Love the goconvey package, thanks for the awesome efforts!

from assertions.

mdwhatcott avatar mdwhatcott commented on August 11, 2024

Thanks for the tip @rana - I saw that recently (and now that I step back and think about it, that's probably where I got the idea to make use of the Equal method). I like that they are calling the Equal method from both directions to root out non-deterministic and/or non-symmetric scenarios (https://github.com/google/go-cmp/blob/master/cmp/compare.go#L369).

from assertions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.