File: corrupt.cc

package info (click to toggle)
yapet 0.6-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 6,012 kB
  • ctags: 2,913
  • sloc: ansic: 13,661; cpp: 11,384; sh: 4,814; makefile: 847; yacc: 291; sed: 16
file content (42 lines) | stat: -rw-r--r-- 923 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// $Id: corrupt.cc 2845 2009-09-01 09:33:31Z rafi $
//
// Checks whether opening corrupt.pet causes an exception to be thrown.
// Corrupt pet has an wrong id string.
//
// Relies on corrupt.pet.

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <typeinfo>
#include <iostream>



#include <file.h>

#define FN "corrupt.pet"

int main (int, char**) {
#ifndef TESTS_VERBOSE
    int stdout_redir_fd = open("/dev/null", O_WRONLY | O_APPEND);
    dup2(stdout_redir_fd ,STDOUT_FILENO);
#endif
    std::cout << std::endl;

    try {
        YAPET::Key key ("corrupt");
        YAPET::File file (std::string (FN), key, false, false);
    } catch (std::exception& ex) {
        // Everything fine...
        std::cout << " ==> " << typeid (ex).name() << ": " << ex.what() << " (OK) " << std::endl;
        return 0;
    }

    return 1;

}