blog

Personal blog
git clone git://git.laack.co/blog.git
Log | Files | Refs

interesting-tests-ive-written.md (1929B)


      1 # Interesting Tests I've Written
      2 
      3 ## Prim's Algorithm
      4 
      5 ### PBT Inadmissable
      6 
      7 Prim's algorithm. Created a comparison for random spanning tree inductions, starting at random vertex of connected graph, select random vertex that's already been visited, follow edges until all vertices have been visited. Assert rnd spanning tree weight <= mst weight.
      8 
      9 https://git.laack.co/abg/commit/4a265d34937ad339697218e4fd919b17b678ab6d.html
     10 
     11 The generalization of this is an algorithmic PBT where we assert an inadmissible heuristic is never better than an admissible heuristic.
     12 
     13 ### Snapshots
     14 
     15 Defined toString() serialization functions for each of my objects, verifying that prior snapshot matches current snapshot. This was interesting because I realized converting from an unordered_map<int,Edge> => vector<Edge>, despite them representing the same data because the ints were from 0 -> n, this changed the ordering of my graph. Good reminder that unordered_map is not ordered, and led me down the rabit hole of figuring out how stable the ordering of unordered_maps actually are. This was interesting too because it reminded me I was relying on the structure of something that wasn't well defined, UB if you will. 
     16 
     17 ## Vet
     18 
     19 ### E2E Time Test
     20 
     21 Time based e2e test for specific command. vet --help, and some other stuff was stupidly fucking slow because of imports of model providers so I wrote a test to assert this wasn't slow. This actually caught an issue with a PR someone submitted to me. 
     22 
     23 This could've been a snapshot-type test too, but that'd have perhaps been too stringent / subject to variance.
     24 
     25 There is potential for issues w/ this type of test, but it seems to generally be within reason when the time deltas are very large, and your infra is pretty okay, even github action runners!
     26 
     27 ## Watermelon Problem
     28 
     29 ### Oracle
     30 
     31 Generation of inputs and outputs using a naive algorithm and then verifying io for the proper algorithm.