vector.com|Contact
Search tips

apple banana
Find rows that contain at least one of the two words.

+apple +juice
Find rows that contain both words.

+apple macintosh
Find rows that contain the word 'apple', but rank rows higher if they also contain 'macintosh'.

+apple -macintosh
Find rows that contain the word 'apple' but not 'macintosh'.

+apple ~macintosh
Find rows that contain the word 'apple', but if the row also contains the word 'macintosh', rate it lower than if row does not. This is "softer" than a search for '+apple -macintosh', for which the presence of 'macintosh' causes the row not to be returned at all.

+apple +(>turnover >strudel)
Find rows that contain the words 'apple' and 'turnover', or 'apple' and 'strudel' (in any order), but rank 'apple turnover' higher than 'apple strudel'.

apple*
Find rows that contain words such as 'apple', 'apples', 'applesauce', or 'applet'.

"some words"
Find rows that contain the exact phrase 'some words' (for example, rows that contain 'some words of wisdom' but not "some noise words").

By continuing to use this site you agree to the use of cookies. For more information and to find out how to change this click here. Accept Cookies
Please enable cookies in your browser for this website.
Search:
Advanced search

Simulate Incoming File, Stub fopen() Function

Last updated: 2019-11-07
Question:
Is there a way to simulate an incoming file, if I am looking to stub the fopen(...) function?
Answer:

To stub fopen, create a new environment or update your existing environment. In step 6 (choose UUTs & Stubs) of the environment wizard, add fopen to the list of library stubs. Make sure the checkboxes next to both are checked. Then build as usual. As long as one of your units under test makes a call to fopen, then it should appear as a stub.
 


 
There is no dedicated feature for simulating file opens/reads. 

If you wanted the file contents which are read to be completely configurable in the test case, a general approach would be to:

  • create a global variable in user code whose purpose will be to hold the file contents. This would presumably be some sort of string variable.
  • create a library stub for fopen().
  • add user code for fopen which will: read the contents of the global variable, write them to a temporary file, call the real fopen() to open the temporary file, and finally return the resulting FILE*.
  • in a test case, add user code to set the global to the desired file contents.
     
 
Article Options
2019-11-07
Views: 6