Add sample/construct_index_main.cpp
Fix bug and Add test