Android: Provide Local Asset in Testing

Posted by in Software

In the past few days I had a little bit of a problem: InstrumentationTestCase gives access to local assets while AndroidTestCase gives access to getAssets() for assets specific to testing. I had a scenario to test where I get a file from my local src/androidTest/assets directory while the code would need to write some files in /data/data/ directory. Quite unfortunate I’d say. My solution was to create an InputStream method based on this answer, to cover both cases. The code is:

This way, if the method is called from…read more

C Optimisation – 2005 style

Posted by in Software

TL;DR: This post is about an experience I had in 2004 and it’s part of my consolidating technical posts I wrote in time. It may or may not be relevant to today’s technologies. I was trying to optimize a bit of code and found out that 2 if() statements are quicker than a case with true/false. and an if/else case is WAY quicker!!! All with various optimisation levels (from nothing to O3 to O3 + architecture optimisations). Odd. one might believe that the switch/case statement would create a static jump…read more