Code Monkey home page Code Monkey logo

Comments (5)

kytrinyx avatar kytrinyx commented on August 15, 2024

That's weird (and frustrating).

I think the tests are expecting the type to be Integer not Long Is there a way to write the tests so that it would accept either? It seems to me that the underlying type is not important in this case so long as the code produces the correct results.

from java.

Akrome avatar Akrome commented on August 15, 2024

The quickest fix I can think of is

assertEquals(expectedOutput -  PrimeFactors.getForNumber(input), 0);

Otherwise we could explicit add casts to long for both sides of the assert.

A bit hacky, but working. Maybe JUnit has something better to offer, though I'm not aware of it.

from java.

Akrome avatar Akrome commented on August 15, 2024

Also, the last test passes in a Long. While its factors are all within the Integer range, it's probably best to just convert the whole test to use all longs?

from java.

kytrinyx avatar kytrinyx commented on August 15, 2024

Yeah, let's just use longs everywhere.

Otherwise we could explicit add casts to long for both sides of the assert.

That might not be a bad idea, actually. The downside is it might look like we think it's a good practice, whereas it would probably be best to avoid in the real world.

from java.

Akrome avatar Akrome commented on August 15, 2024

Given that the last test requires a Long input, I also prefer going with longs everywhere.

from java.

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.