GithubHelp home page GithubHelp logo

Napsat testy about roboprojekt HOT 4 CLOSED

pyladiescz avatar pyladiescz commented on July 17, 2024
Napsat testy

from roboprojekt.

Comments (4)

zstankova avatar zstankova commented on July 17, 2024

První test je v #27

from roboprojekt.

befeleme avatar befeleme commented on July 17, 2024
def get_tiles(data):
    """
    Return the complete list of tiles.
    data: a dict created from decoded Tiled 1.2 JSON file
    Get the list of all tiles from the list "data" within the list "layers". 
    """
    rotation_dict = {0:0, 10:90, 12:180, 6:270}
    tilelist = {}
    for layer in data['layers']:
        tilelist_layer = []
        for data in layer['data']:
            real_tile = data & 0xFFFFFF
            rotation_index = data >> (4*7)
            rotation = rotation_dict[rotation_index]
            tile = Tile(real_tile, rotation)
            tilelist_layer.append(tile)
        tilelist[layer['id']] = tilelist_layer
    return tilelist

Divam se na tuto funkci a zjistuju, ze nevim, jak ji testovat.
Zaprve - dela strasne moc veci a pro ty testy mam chut ji rozkouskovat minimalne jeste na:

  • get_decimal_id_from_hex(int) -> int (v desitkove soustave)
  • get_decimal_rotation_from_hex(int) -> int (v desitkove soustave)

pak se zde vytvari objekty tridy Tile, ktere se pridaji do seznamu dane vrstvy, a ty pak do slovniku. Slovnik ma nasledne podobu, u ktere taky nevim, jak nadefinovat test, priklad nize:

{1: [<__main__.Tile object at 0x7ff32797f5c0>, <__main__.Tile object at 0x7ff32797f5f8>, <__main__.Tile object at 0x7ff32797f630>, <__main__.Tile object at 0x7ff32797f668>, <__main__.Tile object at 0x7ff32797f6a0>, <__main__.Tile object at 0x7ff32797f6d8>, <__main__.Tile object at 0x7ff32797f710>]}
Any ideas? @encukou, @zstankova ?

from roboprojekt.

encukou avatar encukou commented on July 17, 2024

Začni těma dvěma menšíma funkcema.

Výsledek se dá testovat tak, že zkontroluješ např. tilelist[1].rotation == 0. (V úterý k tomu pak můžu říct víc, dej to na agendu.)

from roboprojekt.

encukou avatar encukou commented on July 17, 2024

get_decimal_id_from_hex(int) -> int (v desitkove soustave)

Číslo samo o sobě není v nějaké soustavě, jen se tak dá zapsat. 16 a 0x10 je ta samá hodnota, jen jinak zapsaná. Podobně jako „modrý robot“ a „Ivetin robot“ jsou jen jiné popisy téhož.

Lepší názvy funkcí by byly get_tile_id a get_tile_rotation.

from roboprojekt.

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.